php readfile download
我用apache架设的服务器 在网盘里下载 文件 用如下代码
header(content-type: application/$kind);
header(content-disposition: attachment; filename=$filename);
readfile($requireurl);
//$requireurl=http://59.64.194.138/websvnwin/filedetails.php?repname=lvyang&path=%2fpicture%2fdesert.jpg
我确定 直接 在浏览器下 输入 以上 链接 图片 会显示 出来
但是 readfile却 失败 请问 可能出现的问题和解决 方法
//http://59.64.194.138/websvnwin/dl.php?repname=lvyang&path=%2fpicture%2fdesert.jpg&rev=447&peg=447
用这个链接 却能直接下载? 求分析
而 以上链接 当文件是个 中文名 例如 “dl灯 楼.jpg却下载失败
http://59.64.194.138/websvnwin/dl.php?repname=lvyang&path=%2fpicture%2fdl%e7%81%af%e6%a5%bc.jpg&rev=447&peg=447
------解决方案--------------------
php codeheader(content-type: application/octet-stream);header(accept-ranges: bytes);header(accept-length: . filesize($filedir . $filename));header(content-disposition: attachment; filename= . $filename);
------解决方案--------------------
运行时配置
这些函数的行为受 php.ini 中的设置影响。
文件系统和流配置选项
名称 默认值 可修改范围 更新记录
allow_url_fopen 1 php_ini_system 在 php user_agent null php_ini_all php 4.3.0 版以后可用。
default_socket_timeout 60 php_ini_all php 4.3.0 版以后可用。
from php_ini_all
auto_detect_line_endings 0 php_ini_all php 4.3.0 版以后可用。
这是配置指令的简短说明。
allow_url_fopen boolean
本选项激活了 url 形式的 fopen 封装协议使得可以访问 url 对象例如文件。默认的封装协议提供用 ftp 和 http 协议来访问远程文件,一些扩展库例如 zlib 可能会注册更多的封装协议。
note:
出于安全性考虑,此选项只能在 php.ini 中设置。
note:
此选项是紧接着版本 4.0.3 发布后引进的。版本 4.0.3 以及之前的版本只能在编译时通过配置项 --disable-url-fopen-wrapper 来取消此特性。
warning
windows 版在 php 4.3.0 之前,以下函数不支持远程文件访问:include(),include_once(), require(),require_once() 和gd and image 函数中的 imagecreatefromxxx 函数。