I have a form where the entries on the form are getting saved to a database.
That part works. however part of the form is for instructor to upload 4 documents.
I want to files uploaded a folder on the website and the path to be saved in the db.
How do i handle the file upload part of it. I have seen various posts, but I want the files to be renamed to a name made up of the users id and a few other session variables.
This isn't about having multiple 'action' attributes on the form tag, so I would suggest you rename the thread to avoid confusion.
It's really quite simple. First of all, you need to make sure you have an attribute in your form HTML tag called "enctype" with value "multipart/form-data". That will allow uploads to go ahead.
Then, when you've checked if the form has been sent, you have full control over where you move their files to. There is no reason whatsoever that I can think of that you'd want to rename the files to anything special, because they're being saved in the database.
So all you really need to do is give them a completely random name, and anyone who wants to access them could access them by getting the filename from the database based on a given clause.
The first thing you really, really need to do is just play around with file uploading. No book, forum post or tutorial will give you a complete understanding of how to use everything, just like words cannot help someone to ride a bike. You need to try it out, play around with it and see what it can do and THEN work out how to implement it.
This topic is now closed. New replies are no longer allowed.