I'm creating a web app (locally, so security doesn't matter) in PHP where the user uploads a set of information and a small .jpeg, which is then inserted into a mySQL table. I can do this no problem with all the text data, but I'm not sure how to cause the image to upload alongside it. I assume I will have to use the blob data type and input type="file", but I fooled around with that a little bit and the solution doesn't seem to be an intuitive extension of how input type="text" works. Do I need to do a lot more PHP scripting to get this to work? Is it possible to upload an image with a form, or is there a necessary intermediate step?
A:
http://bytes.com/topic/php/insights/740327-uploading-files-into-mysql-database-using-php
Google for "put uploaded file into mysql with php" and you'll find a whole host of examples/tutorials.
NuclearDog
2010-03-31 01:02:56
A:
Storing the image data in the database itself isn't a good solution.
What I would suggest is storing the image on the file system in a folder and a reference to its name and location is stored in the database.
This Php class will make writing the app a lot easier, "class.upload.php": http://www.verot.net/php_class_upload.htm It comes with lots of examples and has an active support forum. All you need to add to it is the storage of the file name and location in the database.
seanieb
2010-03-31 01:05:35
Thanks! That helps.
paracaudex
2010-03-31 01:34:19