PHP 强制性文件下载功能的函数代码(任意文件格式)
PHP 强制性文件下载功能的函数代码(任意文件格式)
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:/*********************@file-pathtofile*/functionforce_downloa...

复制代码 代码如下:

/********************

*@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函数代码

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新php教程学习
热门php教程学习
编程开发子分类