Jump to content

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...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.