做了一个php下载页面,用到readfile(filepath)or die("File not found.");总是提示文件找不到。
下载文件相对于down.php在 ./admin/Upload 下,而我在down.php中用到的路径 filepath 是./admin/Upload/xxx.xxx
请问文件路径存在问题吗?应当怎样呢?
下载文件相对于down.php在 ./admin/Upload 下,而我在down.php中用到的路径 filepath 是./admin/Upload/xxx.xxx
请问文件路径存在问题吗?应当怎样呢?
解决方案 »
- 为什么总是Warning: mysql_fetch_object(): supplied argument is not a valid MySQL resul
- PEAR HTTP_UPLOAD ajax处理时file为空
- PHP 客户端 与 C 服务器端使用socket通信
- 在函数中如何引用类对象
- 重新提问,郁闷啊。。。。。怎么按照规则把这个数据 array_merge
- vc++ mysql+php,c出现乱码
- 边开发,边学习PHP+Smarty+Ajax
- PHP如何简单快速获取当前URL地址(包括后面参数)
- 请问如何用php实现文本分页显示?
- 关于微信开发模式的PHP代码
- PHP合并数组的问题
- 用javascript打开文本选择对话框
<?php
$file_path=$_GET["path"];
$file_name=$_GET["name"];
//$fp=fopen($file_path,"r");
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($file_path));
header("Content-Disposition: attachment; filename=".$file_name);
readfile($file_path) or die("File not found.");
//echo fread($fp,filesize($file_path));
//fclose($fp);
?>
文件结构:
down.php
./admin/Upload/xxx.xxx
为什么文件明明存在却下载不下来,下载下来的文件里只有提示File not found.
$file_path=$_GET["path"];
$file_name=$_GET["name"];
$file_name=$file_path.$file_name;
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($file_name));
header("Content-Disposition: attachment; filename=".$file_name);
readfile($file_name) or die("File not found.");
?>
file_path=$_GET["path"];
$file_name=$_GET["name"];
$fp=fopen($file_path,"r");
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($file_path));
header("Content-Disposition: attachment; filename=".$file_name);
//readfile($file_path) or die("File not found.");
echo fread($fp,filesize($file_path));
fclose($fp); 用fopen()呢?
用fopen()一样的啊。也是提示找不到文件。
本地测试好像没问题,传到服务器上总是file not found.