Register and display image in PHP database

Asked

Viewed 283 times

1

Hello, I would like to know how I can register an image in the database and how do I display - there I searched on the internet and saw that the field in the bank has to be as longblob or has to be varchar,because I watched in a tutorial where the guy puts varchar in the field where he saves the image. Thank you!

  • Do you use any framework or is with pure PHP?

  • I’m only using PHP itself.

  • I don’t know if it is possible to save an entire image in the database, but what is usually done is to save only the image name in the database (with a randomly generated name, to avoid conflicts) and move the file to a folder. I don’t think I can help you, but there’s this link with a tutorial pro PHP 5, maybe it’s a good starting point.

  • Oh yes,then in case I save the name of the image,and I have to have it in my directory too ? More or less that..

1 answer

0


Friend, possible is. There is a file type in Mysql called blob. I have tried some tests to save an image inside Mysql, never worked cool, the image is very distorted.

The ideial is to save the image url in the database and upload file.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.