开发者

Generic table structure for storing files/images in database

开发者 https://www.devze.com 2023-03-29 13:08 出处:网络
What fields do you think I need to store/retrieve files generically? I am thinking: name (varchar) data (blob)

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)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号