Complete website in Rs. 5,000 with Free Hosting & Domain. Offer ends in  00:00:00
Back to Blog

How to download heavy files with slow internet

Use cURL and cPanel to download heavy files easily and fast

May 11, 2023 Updated: May 11, 2023

// increase memory limit to download heavy files
ini_set('memory_limit', '-1');

$url = 'https://example.com/heavy-file.psd';
$output_filename = 'my-file.psd';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, false);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$result = curl_exec($ch);
curl_close($ch);

// write the contents to a file in the same directory (provided permissions etc)
$fp = fopen($output_filename, 'w');
fwrite($fp, $result);
fclose($fp);

GZIP with cPanel

Compress the file on the server.

Extract GZIP file

gzip -d my-file.psd.gz

Extract TAR file

tar -xf my-file.tar
Contact

Got A Question For Us?

Feel free to ask anything directly on call or fill the form and we will contact back within few hours.