Reputation: 119
how to add image file/s to mysql table.I am a programmer I am using php and mysql.
Upvotes: 1
Views: 756
Reputation:
You need to use blob
(or mediumblob
or longblob
depending on the maximum size of images you want to support) data type for storing binary data.
Before inserting, be sure to escape special characters in the binary image data.
$img_data =mysql_real_escape_string(file_get_contents($filename));
Upvotes: 1
Reputation: 780
I usually store the url of the image file rather than the file itself (not too sure how you would do that anyway). I recommend storing the url and using
Upvotes: 0
Reputation: 5662
You shouldn't add the image itself for websites. You upload the image to the server and then save the path into the database. You should be able to then output the path of the file to HTML.
Upvotes: 1