Generic table structure for storing files/images in database
What fields do you think I need to store/retrieve files generically?
I am thinking:
- name (varchar)
- data (blob)
- content_type (varchar)
Also, is there a way in php to programmatically determine content-type when file is uploaded?
(I have already asked the question files in file system or d开发者_运维百科atabase and I have chosen to go with database.)
BLOB
is for store files
Depends of the app requirements but I think is not a good idea to store file in the database
I ended up going with:
- file_id (INT, auto-increment PRIMARY)
- file_name (VARCHAR 255)
- file_data(LONGBLOB)
精彩评论