开发者

uploading a file to the database - symfony

I'm using a form, that needs to be able to upload a PDF/Word doc file and insert it as blob data.

开发者_StackOverflow

I am using Propel and SF1.4.

Is there a way I can do this? I've only ever seen uploading images to the database.

Thanks


It is certainly possible, the method is the same as with the image files - after all, both are just blobs for the database.

However, you should reconsider this plan. Databases are not meant for such data, but filesystems are great! If you need permission control, store the files outside of your webroot, and have an action that:

  • checks if the user has permission to download the file
  • Sets the correct headers (content-type, content-disposition, etc.)
  • serves the file via readfile or fpassthru or something similar

This would be faster and a lot easier to create and maintain.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜