MySQL Record of Images
Tuesday May 30, 2006
Recently qamarulhuda posted in our forum:
"I know how to submit data into a mySQL table through a form. Now I want to upload the image file to the remote directory (say, 'images/') but at the same time save the file-name in the table."
This is a very good way to keep track of uploads. You can associate a file with a user in the database, but not bog things down by saving the file directly into the database. We have tutorials about uploading files, and about adding data from forms. We just need to combine these concepts together, and have it do both things. Our new tutorial gives a demonstration of how to do this.
"I know how to submit data into a mySQL table through a form. Now I want to upload the image file to the remote directory (say, 'images/') but at the same time save the file-name in the table."
This is a very good way to keep track of uploads. You can associate a file with a user in the database, but not bog things down by saving the file directly into the database. We have tutorials about uploading files, and about adding data from forms. We just need to combine these concepts together, and have it do both things. Our new tutorial gives a demonstration of how to do this.


Comments
Hello Angela,
Im Tiago and Im from Rio de janeiro, Brasil. Im trying to learn about php & MySQL and your tutorials are very helpful tanks for that!
Im having a problem in the “Upload a File and write to MySQL” tutorial. Im checked the path and my password many times and i keep having the message “permision denied”. The complete message is:
________________________________________________
“Warning: move_uploaded_file(img/Photo 116.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/restricted/home/schardongdesign/public_html/add.php on line 21
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move ‘/home/restricted/home/schardongdesign/tmp/phpUsn37o’ to ‘img/Photo 116.jpg’ in /home/restricted/home/schardongdesign/public_html/add.php on line 21
Sorry, there was a problem uploading your file.
________________________________________________
If you have an idea about what am I doing rong please tell me!
Tanks!
Hi Tiago,
Your file permissions must be wrong they need setting to 777. This is relatively easy to do if you use an FTP client e.g. Cyberduck or Transmission simply right mouse click on the “uploads” folder and change the settings to read/write/modify for all e.g. 777.
Hope this helps.
Thanks
Gareth Jones