开发者

newbie: how to upload images from a form with PHP and mySQL

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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜