我正在开发基于内容的WAP应用程序,我必须在其中放置
选定内容上的下载按钮。内容可以是(MP3,WAV,MP4,3gp,图像)。内容名称为9位随机数字字符,如132432498.mp3
, 814274691.mp4
。我试过下面的代码
<?php if(isset($_GET['fileId'])){
$fileid = $_GET['fileId'];
{
i retrieve content content path and name together
like $filename="myserverip/1/3/4/132432498.mp3"
}
then
header ("Content-type: octet/stream");
header ("Content-disposition: attachment; filename=".$filename.";");
header("Content-Length: ".filesize($filename));
readfile($filename);
exit;
?>
< a href= < ? php echo $filename; ?>>Download < /a> '
但文件自动下载名称为132432498.mp3
。我需要帮助写上述内容的名称,因为我的愿望。如何在php中做到这一点?
可能你提供了一个有空格的名字,你必须防止它被双引号括起来,像这样:
header('Content-Disposition: attachment; filename="'.$filename.'"');