开发者

PHP redirect without change current url?

We have some mp3 file collection and flash player used this mp3 file, to track mp3 file listing we render mp3 file using php file below is code

http://www/example.com/getFile.php?fileid=12

<?php
$id = $_REQUEST['fileid'];

// Some code to store download traking and get filename for this id in $filename var.
$filename = getFileName($id);

header('Content-type: audio/mpeg');
header('Content-Disposition: filename=' . $id . '.mp3');
readfile($filename);

?>

But mp3 file size in very big and player get break in IE, for that we also use below code

<?php
$id = $_REQUEST['fileid'];

// So开发者_Python百科me code to store download traking and get filename for this id in $filename var.
$filename = getFileName($id);

header('Location: '. $filename);
?>

this code working fine but its also chnages current URL i.e http://www/example.com/getFile.php?fileid=12 to http://www/example.com/files/xyz.mp3

so user can easily download mp3 file direct how i prevent this? using php or other way ?


Let Flash fetch the file. Return just the URL to Flash through the PHP.


(Sorry, didn't read the question properly when I originally posted - I see now that the problem is with IE and large file size)

You could try telling IE the length, and flushing the buffers:

header('Content-Length: ' . filesize($file));
ob_clean();
flush();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜