1

Is it better to store uploaded general files (images, pdf, etc) from users in a MySQL database or should I store in them in file directories? I'm curious in terms of performance and also the security of each option.

Thanks!

2 Answers 2

1

I would suggest storing them in the filesystem and storing a reference to the file in the DB. I'm not that one is tremendously more performant than the other, but the advantage of having them in the filesystem is that you can access the files in other contexts. This makes them easier to organize, move around, manipulate, etc. If they are just blobs in the DB, you have to go through MySQL each time.

0
1

Personally, I find it a lot faster to store the uploaded file in a folder and store the path to the file in the DB.

This will also keep your DB file size smaller, which is great for backing up too.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.