I have a question about how the upload and download system works with php and mysql.
I would like to be able to upload files (preferably through my webpage) so that only a specific user can view available files sorted in some catagories and download the ones he/she wants.
I feel really stupid asking this but where is the files then saved? Inside a table? Or does the table point to a directory in my webserver?
I’m asking this as I really want to learn this but even the basic questions can be difficult even to formulate let alone solve… 🙂
Looking forward for some input
Cheers
Adam
The PHP file upload is actually a two step process(if you want to save it to a desired path). The $_FILES variable has all the details when you try to upload a file, which includes, Name, type, size and temp_name. The temp_name actually contains the temporary path of the file. You can then make use of move_uploaded_file function to move the file to whatever path you want to.
About saving in the database, once you are able to successfully move the file to the desired location, you can update your database. I would suggest, it would be better to have a table just for files names and id and I am assuming you might have a table for users as well. You can then have a new table which can map user id and file ids. That would give you ability to share access among users. Of course there are others ways to do it as well. I think this might be a simple implementation.
Also I just realized, that you might want want to look at a simple file upload example. You can refer to this link