How to download a large file on your server using PHP?

This tutorial is only for those who want to copy a file from one website to another. If there is a large file you want to download on your website/server from another website, there is no need to first download it on your computer and then upload it using FTP. There’s an easier way to do this.

Step 1) Using FTP Manager, or any FTP client go to the directory where you want to download the file.

Step 2) Create a php file with this code:


<?php

file_put_contents("files.zip", fopen("fileurl here", 'r'));
echo "Done";

?>

Step 3) Open the php file in the browser. For example if you created the php file in the root folder of your WordPress site, you will go to: yoursite.com/phpfilename.php

You can also achieve the same using Putty/SSH. Navigate to the folder where you want to download a file and run this code:


wget fileurlhere

Leave a Reply

Your email address will not be published. Required fields are marked *