简体   繁体   中英

How to store images in databases like mysql or oracle?

I want to store images in a database. How this can be done using a Php page.

It's not a good idea to store images in DB because the database gets very huge with relatively a small amount of tupels. Store the path to your image on the filesystem in a column of your table instead. That keeps your databases size smaller. database is for data and a filesystem is for files (as their name already indicates).

If you still want to store images in database. Store images content ( file_get_contents($yourImageFile) ) in a column of type BLOB .

You can save image names to DB and you can use them in your application. Don't forget to put path before the image.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM