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.
开发者_StackOverflowI 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
orfpassthru
or something similar
This would be faster and a lot easier to create and maintain.
精彩评论