Welcome Guest, Not a member yet? Register   Sign In
File upload then store in database with title and description
#1

[eluser]patrick-vibes[/eluser]
Hi Folks,

I am using the basic file upload procedure as per the manual to upload files - this is working great and nice and simple, however -

After the file has uploaded (images) I want to then pass the full_path into a hidden form field on the success page and have two other fields, one for the "title" of the image and another for the "description" - after the user has entered this information they then submit it and it is stored in a mysql table called "images".

Could someone offer some advice, there is no real clear example that I can find for such a request and the forum post I found relating to just passing the full_path into a table doesn't really explain.

Is my approach the best method - uploading then offering the title and description (and hidden path) fields? Or would it be better to do it another way, i.e. offering the title and description and upload function on one upload page and doing it all from that?

Thanks in advance.
#2

[eluser]TheFuzzy0ne[/eluser]
I'm not saying you're wrong here, but I would be interested to hear why you feel you need to do this over two requests.
#3

[eluser]patrick-vibes[/eluser]
I have no preference for doing it over 2 requests - it's just the way I was getting my head round it - I am fairly new to CI and using it now as a project to learn more and be able to build modules for a bespoke CMS.

How would I go about doing this in the one request? I assume it would be acase of adding a db insert into the upload controller?
#4

[eluser]TheFuzzy0ne[/eluser]
I guess it's best to do it the way you're users will find easiest. If you want allow users to upload images without a title and description, then 2 forms would probably work quite well, otherwise you're likely to experience anomalies where images have no corresponding database entry (which, of course, can be coded around).

Yes, you would just need to do a database insert from your upload controller - after you've validated the users input, of course. Smile

I'm not sure how this sounds to you, but if you did it the other way around, where the user specifies the title and description before they upload the image, you could store the title and description in the cookie, and then use that once the image has been uploaded. If an image is uploaded, and the cookie data is not there, then the user has not arrived via the previous page. Obviously, with multi-page forms, this is something you need to bear in mind. It's easy enough to code around, however, by checking for the data in the cookie, and doing a simple redirect to the previous page if it doesn't exist.
#5

[eluser]phpserver[/eluser]
I hope this helps: http://net.tutsplus.com/tutorials/php/cr...deigniter/
#6

[eluser]phpserver[/eluser]
http://net.tutsplus.com/tutorials/php/cr...deigniter/
#7

[eluser]Dam1an[/eluser]
It appears I'm not the only one that follows nettuts Smile
My personal preference is to do it all in one go, users are impatient, and a multi part form for what is really a single action (as far as the user is concerned) will just annoy them

The only potential reason for doing it over 2 parts, is if you where to take the file name as the suggested title and maybe somehow extract a description from either meta data, or if its a text file, the first sentance or 2
#8

[eluser]phpserver[/eluser]
:coolsmile: Nettuts rocks
#9

[eluser]patrick-vibes[/eluser]
I read that tutorial at netuts - sme of the comments made me a bit weary of some of the methods used.

The actual ap I am making is intended to host .swf files. I am trying to build it similar to netuts file sharing app, where users have to register to use it but would have a more extensive profile - then they can upload several swf files and organise them into albums. They then are able to generate an embed code for the album similar to a youtube object embed to use the swf album on other sites etc.

When a users uploads the swf files they need to be able to give them a title and description to keep track of them when they view the album listings - otherwise the filenames (which I will hash) will make no sense and I dont want to print out a list of the swf's like thumbs because it will make the page heavy as each swf loads.
#10

[eluser]Dam1an[/eluser]
What comments made you weary of the code used? You need to remember these sorts of tutorials often dumb other parts down to not get distracted (such as the user part in this case, its just a simple login)

Creating profiles, albums etc shouldn't be a problem... I've nevr tried creating an embedded flash player, so not sure about that one




Theme © iAndrew 2016 - Forum software by © MyBB