PHP重定向没有更改当前URL?

时间:2011-01-13 05:53:58

标签: php flash .htaccess redirect mp3

我们有一些mp3文件集和flash播放器使用这个mp3文件,跟踪mp3文件列表我们使用php文件渲染mp3文件下面是代码

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);

?>

但是非常大的MP3文件大小和玩家在IE中获得了突破,因为我们也使用下面的代码

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

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

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

此代码工作正常,但它也是chnages当前URL 即http://www/example.com/getFile.php?fileid=12http://www/example.com/files/xyz.mp3

所以用户可以轻松下载mp3文件直接如何防止这种情况?用php或其他方式?

2 个答案:

答案 0 :(得分:1)

让Flash获取文件。通过PHP返回Flash的URL。

答案 1 :(得分:0)

(对不起,我最初发布时没有正确阅读问题 - 我现在看到的问题是IE和大文件大小)

您可以尝试告诉IE长度,并刷新缓冲区:

header('Content-Length: ' . filesize($file));
ob_clean();
flush();
相关问题