Pushan
Pushan

Reputation: 119

adding image files to database table

how to add image file/s to mysql table.I am a programmer I am using php and mysql.

Upvotes: 1

Views: 756

Answers (3)

JP19
JP19

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

Dartoxian
Dartoxian

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

Matt Asbury
Matt Asbury

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

Related Questions