PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

PHP 强制性文件下载功能的函数代码(任意文件格式)_PHP教程

原创
2016-07-21 15:37:54 651浏览

复制代码 代码如下:

/********************
*@file - path to file
*/
function force_download($file)
{
if ((isset($file))&&(file_exists($file))) {
header("Content-length: ".filesize($file));
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $file . '"');
readfile("$file");
} else {
echo "No file selected";
}
}

这里是摘自脚本之家之前发布的文章。更多的技巧可以参考。
收集的二十一个实用便利的PHP函数代码

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/321868.htmlTechArticle复制代码 代码如下: /******************** *@file - path to file */ function force_download($file) { if ((isset($file))(file_exists($file))) { header("Content-length: ".files...
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。