有关文件下载是弹出"保存到磁盘还是在当前窗口打开"对话框,高手请教小弟!急,线上等! 改文件后缀。没别的办法。WEB服务器一看是PHP的请求就会做处理的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 点击下载链接,提交给这个php<?php download_file("../../../challenge/config/csv/C_0001.csv"); exit(); function download_file($path_file){ ini_set('max_execution_time', 600); if (!file_exists($path_file)) { die("Error: File(".$path_file.") does not exist"); } if (!($fp = fopen($path_file, "r"))) { die("Error: Cannot open the file(".$path_file.")"); } fclose($fp); if (($content_length = filesize($path_file)) == 0) { die("Error: File size is 0.(".$path_file.")"); } header("Content-Disposition: inline; filename=\"".basename($path_file)."\""); header("Content-Length: ".$content_length); header("Content-Type: application/file"); if (!readfile($path_file)) { die("Cannot read the file(".$path_file.")"); } ini_set('max_execution_time', 30); }?> 是不是在上传时该文件的后缀,把我解析出来的后缀名$pieces,该成什么呢? $path_file 是不是我下载的文件“/fname/<?php echo $data[upname];?>, ???????? 就是你要下载的文件(带PATH)。 我是这样写的 :<?php download_file("../../../challenge/config/csv/C_0001.csv"); exit(); $path_file = "/usr/www/html/sinobone/fname/$data[pic_name]"; function download_file($path_file){ ini_set('max_execution_time', 600); if (!file_exists($path_file)) { die("Error: File(".$path_file.") does not exist"); } if (!($fp = fopen($path_file, "r"))) { die("Error: Cannot open the file(".$path_file.")"); } fclose($fp); if (($content_length = filesize($path_file)) == 0) { die("Error: File size is 0.(".$path_file.")"); } header("Content-Disposition: inline; filename=\"".basename($path_file)."\""); header("Content-Length: ".$content_length); header("Content-Type: application/file"); if (!readfile($path_file)) { die("Cannot read the file(".$path_file.")"); } ini_set('max_execution_time', 30); }?> <a href = "/fname/<?php echo urlencode($data[pic_name])?>" target=_blank>[更多内容上传、请点击此处下载查看]</a> 它产生这样的错误: Fatal error: Call to undefined function: download_file() 把 download_file("../../../challenge/config/csv/C_0001.csv"); exit();放到最后不然exit();了就无法调用后面的函数了 给你写了个sample,自己看看再对着改。1.sample.html<html><head><meta http-equiv="Content-Type" content="text/html; charset=GB2312"><!--- <META HTTP-EQUIV="Pragma" CONTENT="no-cache"><META HTTP-EQUIV="Cache-control" CONTENT="no-cache"><META HTTP-EQUIV="Expires" CONTENT="0"> ---><title>sample</title><SCRIPT language="JavaScript"><!--function send(filename){ document.formMain.downloadfile.value = filename; document.formMain.action = "sample.php"; document.formMain.submit();}//--></script></head><body topmargin="5" bgcolor="#ffffff"><form name="formMain" method="post"><input type="hidden" name="downloadfile"><P align=center><B><A href="javascript:send('abc.jpg');">download</A></B></P></form></BODY></HTML> 2.sample.php<?php download_file("/abc/fku/html/sxye/sinobone/fname/".$_POST["downloadfile"]); function download_file($path_file){ ini_set('max_execution_time', 600); if (!file_exists($path_file)) { die("Error: File(".$path_file.") does not exist"); } if (!($fp = fopen($path_file, "r"))) { die("Error: Cannot open the file(".$path_file.")"); } fclose($fp); if (($content_length = filesize($path_file)) == 0) { die("Error: File size is 0.(".$path_file.")"); } header("Content-Disposition: inline; filename=\"".basename($path_file)."\""); header("Content-Length: ".$content_length); header("Content-Type: application/file"); if (!readfile($path_file)) { die("Cannot read the file(".$path_file.")"); } ini_set('max_execution_time', 30); }?> to zhuomaocn(烦啊) 你的这个也是直接打开的. php开发.整合多个入口! php.ini的safe_mode探讨! 在看网上的cms时,经常看到某个对象在用,却找不到这个类是在哪里定义的。怎么办? 关于更新数据库问题! 如何在php中监听一个多行列表中一行的一个列被点击了? 请问概念上都能理解,具体操作上就不会了,怎么办呢 中括号的作用是什么???? fsockopen的问题,写入头信息的时候,get,post方法问题 散点分,谈谈最近学习心得体会 搜索学多科学员的SQL语句怎么写? 各位高手,怎么取IE的语言版本呢? 连接oracle817时提示找不到OCILogon(),还要怎么配置?
<?php
download_file("../../../challenge/config/csv/C_0001.csv");
exit();
function download_file($path_file){
ini_set('max_execution_time', 600);
if (!file_exists($path_file)) {
die("Error: File(".$path_file.") does not exist");
}
if (!($fp = fopen($path_file, "r"))) {
die("Error: Cannot open the file(".$path_file.")");
}
fclose($fp); if (($content_length = filesize($path_file)) == 0) {
die("Error: File size is 0.(".$path_file.")");
} header("Content-Disposition: inline; filename=\"".basename($path_file)."\"");
header("Content-Length: ".$content_length);
header("Content-Type: application/file"); if (!readfile($path_file)) {
die("Cannot read the file(".$path_file.")");
}
ini_set('max_execution_time', 30);
}?>
download_file("../../../challenge/config/csv/C_0001.csv");
exit();
$path_file = "/usr/www/html/sinobone/fname/$data[pic_name]";
function download_file($path_file){
ini_set('max_execution_time', 600);
if (!file_exists($path_file)) {
die("Error: File(".$path_file.") does not exist");
}
if (!($fp = fopen($path_file, "r"))) {
die("Error: Cannot open the file(".$path_file.")");
}
fclose($fp); if (($content_length = filesize($path_file)) == 0) {
die("Error: File size is 0.(".$path_file.")");
} header("Content-Disposition: inline; filename=\"".basename($path_file)."\"");
header("Content-Length: ".$content_length);
header("Content-Type: application/file"); if (!readfile($path_file)) {
die("Cannot read the file(".$path_file.")");
}
ini_set('max_execution_time', 30);
}
?>
<a href = "/fname/<?php echo urlencode($data[pic_name])?>" target=_blank>
[更多内容上传、请点击此处下载查看]</a> 它产生这样的错误:
Fatal error: Call to undefined function: download_file()
download_file("../../../challenge/config/csv/C_0001.csv");
exit();放到最后不然exit();了就无法调用后面的函数了
1.sample.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<!--- <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0"> --->
<title>sample</title>
<SCRIPT language="JavaScript">
<!--
function send(filename){
document.formMain.downloadfile.value = filename;
document.formMain.action = "sample.php";
document.formMain.submit();
}
//-->
</script>
</head><body topmargin="5" bgcolor="#ffffff">
<form name="formMain" method="post">
<input type="hidden" name="downloadfile">
<P align=center><B><A href="javascript:send('abc.jpg');">download</A></B></P>
</form>
</BODY>
</HTML>
download_file("/abc/fku/html/sxye/sinobone/fname/".$_POST["downloadfile"]); function download_file($path_file){
ini_set('max_execution_time', 600);
if (!file_exists($path_file)) {
die("Error: File(".$path_file.") does not exist");
}
if (!($fp = fopen($path_file, "r"))) {
die("Error: Cannot open the file(".$path_file.")");
}
fclose($fp);
if (($content_length = filesize($path_file)) == 0) {
die("Error: File size is 0.(".$path_file.")");
}
header("Content-Disposition: inline; filename=\"".basename($path_file)."\"");
header("Content-Length: ".$content_length);
header("Content-Type: application/file");
if (!readfile($path_file)) {
die("Cannot read the file(".$path_file.")");
}
ini_set('max_execution_time', 30);
}
?>
你的这个也是直接打开的.