Monday 3 September 2018
Subscribe to:
Post Comments (Atom)
$track = $_SERVER['QUERY_STRING'];
if (file_exists("/home/user/gets/" .$track)) {
header("Content-Type: audio/mpeg");
header('Content-Length: ' . filesize($track));
header('Content-Disposition: attachment; filename="test.mp3"');
$str = "/home/user/gets/".$track;
readfile($str);
exit;
} else {
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found', true, 404);
echo "no file";
}
//$track = $_SERVER['QUERY_STRING'];
$track = 'testfile.zip';
if (file_exists("/home/user/gets/" .$track)) {
header("Content-Type: application/octet-stream");
header('Content-Length: ' . filesize($track));
header('Content-Disposition: attachment; filename="test.mp3"');
$str = "/home/user/gets/".$track;
readfile($str);
exit;
} else {
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found', true, 404);
echo "no file";
}
filesize($track)
is wrong, it should be the whole path filesize("/home/user/gets/".$track)
. This would cause php to output error messages, preventing you from setting the content-length and disposition header.Hello Friends! I am Ramana a part time blogger from Hyderabad.
0 comments:
Post a Comment