这样为什么不能实现文件下载
$root="D:/wamp/www/新建文件夹/";
if(is_dir($root))
{
$openHandle=opendir($root);
while(false!==($file=readdir($openHandle)))
{
if(!is_dir($root.$file))
{
echo "".$file."
";
echo "$root$file
";
}
}
closedir($openHandle);
}
else
{
echo "文件夹不存在";
}
?>
这段代码为什么不能实现文件下载 浏览器:搜狗浏览器 IE 都试了
------解决方案--------------------
用header头下载
------解决方案--------------------
已經幫你寫好了
<?php<br>$root="D:/ghost/";<br>if(is_dir($root)){<br> $openHandle=opendir($root);<br> while(false!==($file=readdir($openHandle))){<br> if(!is_dir($root.$file)){<br> echo "<a href='?do=down&file=".$file."&path=".urlencode($root)."'>".$root.$file."</a><br/>";<br> }<br> }<br> closedir($openHandle);<br>}else{<br>echo "文件夹不存在";<br>}<br><br>$do=(isset($_REQUEST['do'])) ? addslashes($_REQUEST['do']) : '';<br>if($do=='down') {<br> $file=(isset($_REQUEST['file'])) ? addslashes($_REQUEST['file']) : '';<br> $path=(isset($_REQUEST['path'])) ? addslashes($_REQUEST['path']) : '';<br><br> OB_start();<br> function DownLoad($info,$file) {<br> OB_Clean();<br> if(!file_exists($info)) {<br> exit('Error:'.__LINE__.','.basename(__FILE__).'!');<br> }<br> $info=file_get_contents($info);<br><br> header('Content-Transfer-Encoding: binary');<br> header('Content-Type: application/force-download; name="'.$file.'"');<br> header('Content-Disposition: attachment; filename='.$file.'');<br> header('Cache-control: private');<br> header('Pragma: no-cache');<br> header('Expires: 0');<br> echo $info;<br> die();<br> }<br> DownLoad($path.$file,$file);<br>}------解决方案--------------------
file_put_contents('download/excel.csv',$str);
header("location:download/excel.csv"); //让电脑自动弹出下载对话框
bee餐饮点餐外卖小程序是针对餐饮行业推出的一套完整的餐饮解决方案,实现了用户在线点餐下单、外卖、叫号排队、支付、配送等功能,完美的使餐饮行业更高效便捷!功能演示:1、桌号管理登录后台,左侧菜单 “桌号管理”,添加并管理你的桌号信息,添加以后在列表你将可以看到 ID 和 密钥,这两个数据用来生成桌子的二维码2、生成桌子二维码例如上面的ID为 308,密钥为 d3PiIY,那么现在去左侧菜单微信设置









