dongshi1102 2010-03-31 00:56
浏览 51
已采纳

新手:如何使用PHP和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?

  • 写回答

2条回答 默认 最新

  • duanhe1965 2010-03-31 01:05
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?