开发者

Where to store uploaded files in PHP & MySQL?

I'm solving problem of storing files in my web app.

I've already done some applications where files were stored in filesystem (simple upload of a file via PHP) and I wasn't sure how to solve the security issues correctly (I have the webapp on a shared webhosting). Is there any开发者_JAVA百科 "manual" or book which target these issues in detail?

Recently, I've done an webapp where files are stored in MySQL database and it seems to be very easy for usage and I don't need to solve the permissions for the files. The disadvantage is that there's additional overhead of the system.

What is better according to you? (I have small files ~ 100kB)

Thank you!


Each solution has its pros and cons.

Storing files in the DB is great for small files. Just remember to keep the files themselves and any metadata about those files in two different tables. This will prevent your queries from being slowed down by the binary data. Also keep in mind that, overtime, this can lead to very large DB tables.

File system storage is great, but keep in mind that you're going to have to keep file permissions / security in mind moreso than you would if you stored them in the DB.

I hope this steers you in the right direction. Post a comment if you have questions.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜