I develop a code to download a MP3 file from server. The code works in old server but not works in New Server. It shows 0 bytes when i try to download a fine
i send a download link through HTTP Post methos
www.example.com/download.php?dlink=http://www.example.com/music/sample.mp3
Here is the code i used
ob_start();
if(isset($_REQUEST['dlink']))
{
$file = $_REQUEST['dlink'];
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
ob_flush();
Thanks in advance
You should not pass the absolute url in dlink parameter as you cannot read file from remote server.
use this url www.example.com/download.php?dlink=music/sample.mp3
assuming the executable file in root directory.
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.