如何解决下载的FLV文件不起作用
|| 这是我的代码。<?php
ob_clean();
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
// block any attempt to the filesystem
if (isset($params[\'file\']) && basename($params[\'file\']) == $params[\'file\']) {
$filename = $params[\'file\'];
} else {
$filename = NULL;
}
// define error message
$err = \'<div class=\"right-panel fl\">
<h1> Download Question </h1> <a href=\"JavaScript:void(0)\" class=\"button\" onclick=\"javascript:history.go(-1)\" > Back </a>
<div class=\"gradient-box\" style=\"margin-top:20px;\" ><p style=\"color:#990000\">Sorry,the file you are requesting is unavailable.</p></div></div>\';
if (!$filename) {
// if variable $filename is NULL or false display the message
echo $err;
} else {
// define the path to your download folder plus assign the file name
$path = BASE_PATH.QUESTIONS_FILE_PUBLIC.$filename;
$path2 = REL_PATH.QUESTIONS_FILE.$filename;
// check that file exists and is readable
if (file_exists($path) && is_readable($path)) {
// get the file size and send the http headers
$size = filesize($path);
header(\"Content-type: video/flv\");
header(\'Content-Length: \'.$size);
header(\'Content-Disposition: attachment; filename=\'.$filename);
header(\'Content-Transfer-Encoding: binary\');
// open the file in binary read-only mode
// display the error messages if the file can´t be opened
echo file_get_contents($path);
//@readfile($path);
exit;
$file = @ fopen($path,\'rb\');
if ($file) {
// stream the file and exit the script when complete
fpassthru($file);
exit;
} else {
echo $err;
}
} else {
echo $err;
}
}
?>
解决方法
尝试使用此注释中的功能来强制浏览器打开下载文件对话框。它必须有所帮助。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。