Reputation: 31
Help me please!
I'm trying to download the file using script from remote server. Script starts downloading, but hangs (in chrome shows "starting" and hangs).(I installed MAMP locally and tried to download file from local server and it's works fine.)
Maybe there are wrong configurations in php.ini file?
The script i'm using:
<?php
$url = "http://cs4-2v4.vk.me/p22/fbb2ec25fb8f67.mp3";
header("Content-Disposition: attachment; filename=music.mp3");
ob_flush();
flush();
$fp = fopen($url, "rb");
while (!feof($fp))
{
print(fread($fp,8192));
ob_flush();
flush();
}
fclose($fp);
?>
Thanks!
Upvotes: 0
Views: 761
Reputation: 31
Thanks to everyone who responded.
The error was that the file does not exist with this link (file_exists($path) not works for url's). On the local server everything worked because the request came from the same IP address, from under which user has been registered in a social network vk.com.
Upvotes: 0
Reputation: 1347
$file_name = '1353.zip';
$file_url = 'http://download.krizna.com/' . $file_name;
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=\"".$file_name."\"");
readfile($file_url);
Upvotes: 0