Jump to content

Storing files in databases


Daniel0

Recommended Posts

I found that longblobs only allow 2MB which isn't quite enough for me. Is there any way to store larger files or should I store them as files with the filename in the database? How should I prevent users from downloading the files if placing them outside document root is not an option? .htaccess?
Link to comment
https://forums.phpfreaks.com/topic/33333-storing-files-in-databases/
Share on other sites

[code=php:0]
deny from all
[/code]
in an .htaccess file will deny everyone access.

I would do that and then create an attachment.php file that included the file and output the correct headers for the file ext.  And I would just store the file location in the DB and then use attachment.php where you had fileid=X and then it would pull the location from the DB where the ID was the fileid thing.
I suggest never storing files in the database. It's relatively inefficient, and will certainly make your life difficult if you ever want to do any server-side stuff with it. I always recommend storing the file in the filesystem and just storing the path to that file in the database.
  • 5 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.