简体   繁体   中英

How to save a file to my computer using PHP

I'm using PHP and have a file upload page as well as another page to view the uploaded files. The problem is that my web server's ftp only allows a maximum upload size of 5MB but I want to be able to upload larger files.

How can I save these files to my laptop instead of to my web server?

Thank you for your help.

The problem with your possible solution is that, unless you are hosting everything on your laptop, anything that you upload through your website , even if it ends up on your laptop in the end, will still have to pass through your website .

Since your website has php upload limits, these limits will be applied to anything that is transferred through your website through php.

There are several ways to get around this:

  1. Upload everything through FTP (no php).

    Your hosting service has unlimited FTP uploads ("where no file size limits are applied (except for the account size limit)" source ). Since it sounds like you only want a small group of people to be able to upload files, give each of them access to your FTP account. Only one FTP account is allowed for free users. If you aren't a free user give them each an individual FTP account in order to monitor individual usage.

    Check out File Upload Questions for some help with FTP.

  2. Use a php file splitter.

    Since you are limited to a certain size of file per call, use a ready-built php program such as Plupload to manage uploading larger files by splitting them into chunks that are small enough to fit through your php limit. If you are trying to upload a 50MB file with a php limit of 5MB, Plupload will make 10 requests ( 10*5MB=50MB ) splitting your file into 10 pieces so that it will pass through the php limit.

  3. Use online file transferring software.

    Online programs such as Dropbox or WeTransfer allow you to upload and share large files (2GB for WeTransfer and virtually limitless for DropBox). Any files uploaded and downloaded through this method would go through another company's server (not your own) which means that the 5MB limit would definitely not apply. Users can create an account with DropBox and upload to a " shared " folder, or simply upload their files to WeTransfer and you will receive an e-mail that you have a file waiting to be downloaded.

    This method completely skips your server, meaning no 5MB limit, but also meaning that the files won't be stored/accessible on your website.

I hope these suggestions are useful or at least give you something to think about.

Good Luck!

If you can change your php.ini file you could adjust the max upload size

upload_max_filesize = 20M
post_max_size = “20M”

Alternatively you can also do this in your .htaccess file

php_value upload_max_filesize 20M
php_value post_max_size 20M 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM