作者rollman (死命咬著牙...)
看板PHP
標題[請益] 下載檔案的問題
時間Wed Nov 29 01:52:35 2006
這是我的程式
想用下拉式選單 選擇我想要下載的程式
選取後 按下ok 會讓browser盪掉
可是只有單獨php的code的時候又可以順利的執行($file_name=="WDD051001.pdf")
直接用指定的
卻可以下載
請問一下 怎麼解決?
*test.php檔案內容*
<html>
<head>
</head>
<body>
<form name="form1" method="post" action="test.php">
<select name="column1" size=1 >
<option value="Select">請選擇</option>
<option value="WDD051001.pdf">WDD1</option>
<option value="WDD051101.pdf">WDD2</option>
</select>
<input name="submit" type="submit" value="Ok">
</form>
<?
$file_name = $_POST["column1"];
$file_url = rawurlencode($file_name);
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=$file_name");
readfile($file_url);
?>
</body>
</html>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.245.165
1F:推 foxzgerald:Content-Type 是不是打錯阿? 11/29 02:24
2F:→ suckerlove:header前不能印出東西@@ 11/29 05:48