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
精彩评论