kazinix
kazinix

Reputation: 30103

PHP uploading and downloading files

I'm facing a dilemma on how to implement file upload and download in a PHP website.

I have these criteria:

  1. Performance - does not give performance issues to the website
  2. File size - around 2GB and up.
  3. Authorization - I want to be able to change who can access the files in PHP. Allow multiple users to gain access to a single file.
  4. User friendly - no additional tools to use.

So here are the methods I'm currently looking at and how I assess them based on my criteria:

Database BLOB

  1. Writing the file data into the output stream will take time and blocks other requests (is this correct?)
  2. I read somewhere that there's a size limit for BLOB.
  3. OK - I can easily control who can download the files here.
  4. OK - No additional tools, just the website.

FTP

  1. OK - since it is designed to store files.
  2. OK - file system is the limit.
  3. I need to create another credentials for each user aside from the username and password for the website. I assume I have to move the file from one location to another to update authorization, but how if multiple users can access one file? Shared directory? It looks messy.
  4. Need another tools/program for accesing their files, need to remember another username and password.

My questions:

  1. Based on my assumptions, do you thimk I understand the methods correctly?
  2. If my assumptions are wrong, is there a way I can do this functionality while meeting my criteria?

PS Please excuse my English.

Upvotes: 0

Views: 184

Answers (2)

Philipp
Philipp

Reputation: 15629

Why not just use the file system to store the files and store the path to the given file (+ permissions, if needed) in addition in a database.

The upload folder isn't accessible from the public and an wrapper script serves the content to the user.

  1. Performance shouldn't be a problem as you just move/copy the uploaded file to a dedicated data directory.
  2. File size isn't a problem (as long, as you have enough disk space)
  3. The wrapper script handles permissions and serves files to the users
  4. It's as friendly, as you design your ui

Upvotes: 3

Marquis Jules
Marquis Jules

Reputation: 71

for me the usage of BLOB is not the best. I thought about BLOB to upload pictures in my own website, but the best way to upload file is to put them directly on ur server locally.

Upvotes: 2

Related Questions