简体   繁体   中英

How do I save images in a Mysql Database and seperate by date?

How do I save images in a Mysql Database? (and if possible seperate them by dates)

It is usually discouraged to save files in Database. The suggested practice is Files in File-System and Data in Data-Base. : )

But if you have to, see this tutorial Uploading Files To MySQL Database

There are a couple of ways of pursuing this. The most common, and arguably efficient way , would be to save the files to the filesystem and store the paths in the database (and in your case a timestamp).

Alternatively, you can store the image as a BLOB in the database.

You can create a table with id, image as a blob and a date. But I would not recommend it. It is better to save images as files and let your web server serve those. It'll help tremendously with performance, caching, etc

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