 |
พี่ ๆ ดูให้หน่อยค่ะ เขียนโค้ดดาวน์โหลดอย่างงี้มันไม่ได้อ่ะค่ะ |
|
 |
|
|
 |
 |
|
ยังไม่ได้อยู่ดีค่ะ
Code (PHP)
<?
<font class="detailDesc"><font class="css_code">$file = "upload/ACS_brochure.pdf"; //ตรงนี้แก้เป็นที่อยู่ไฟล์ใช่มั้ยคะ line 2
header("Cache-Control: public");
header("Content-Type: application/pdf");
header("Content-Description: File Transfer");
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=" . $file);
header("Content-Length: " . filesize($file));
readfile($file);
</font></font>
?>
ขึ้น error ว่า
Parse error: syntax error, unexpected '<' in C:\AppServ\www\test\Untitled-1.php on line 2
ขอบคุณนะคะ
|
 |
 |
 |
 |
Date :
2010-08-26 11:49:17 |
By :
Nutty |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
if($download_file)
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=".basename($download_file).";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($download_file));
@readfile(($download_file));
}
<a href="?download_file=upload/ACS_brochure.pdf">download</a>
|
 |
 |
 |
 |
Date :
2010-08-26 12:38:43 |
By :
heng |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำไมหนูเอาคำสั่งดาวน์โหลดไปไว้ใน while มันไม่ขึ้น popup ดาวน์โหลดให้คะ มันแค่เข้าไปที่อยู่ของไฟล์อ่ะคะ
Code (PHP)
$sql="select*from upload where type='$jpg'";
$result=mssql_query($sql);
while($row=mssql_fetch_row($result)){
if($download_file)
{header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=".basename($download_file).";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($download_file));
@readfile(($download_file));
}
echo"<a href='?download_file=upload/$row[3]'>download</a>"; // $row[3] คือชื่อไฟล์ค่ะ
}
ผลลพัธ์ว่า
http://localhost/test/download.php?download_file=upload/26703_407839104005_660589005_4671444_6438442_n.jpg
งี้อ่ะค่ะตรง browser ie มันขึ้นงี้ก็แสดงว่ามันเข้าถึงไฟล์แล้ว แต่ทำไมมันไม่ขึ้น popup ดาวน์โหลดคะ
|
 |
 |
 |
 |
Date :
2010-08-26 13:28:02 |
By :
Nutty |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รออยู่นะึคะ
ขอบคุณคะ
|
 |
 |
 |
 |
Date :
2010-08-26 14:10:40 |
By :
Nutty |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอาทั้งหมดไว้นอก while นะ เอาไว้บรรทัดบนสุดด้วย
Code (PHP)
<?
if($download_file)
{header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=".basename($download_file).";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($download_file));
@readfile(($download_file));
}
?>
|
 |
 |
 |
 |
Date :
2010-08-26 15:09:58 |
By :
heng |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่มีวิธีอื่นเหรอคะ ไว้นอกลูปมันก็ขึ้นดาวน์โหลดแค่ไฟล์เดียว ไฟล์อื่นก็ไม่ขึ้น
|
 |
 |
 |
 |
Date :
2010-08-26 16:16:56 |
By :
Nutty |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองแล้วลองอีก .... ยังรอต่อไป
|
 |
 |
 |
 |
Date :
2010-08-26 18:20:26 |
By :
Nutty |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถามได้นะคะ คือมีไฟล์ให้ดาวน์โหลดหลายไฟล์อ่ะค่ะ แล้วตัวแปร row[3] คือชื่อไฟล์ พอใส่ $row[3] ต่อท้าย upload มันก็จะเข้าไปถึงไฟล์
นั้น ๆ อ่ะค่ะ ถ้าใส่ไว้นอกลูป while มันก็จะแสดงดาวน์โหลดอันเดียวใช่มั้ยคะ ไม่แสดงให้ทุกดาวน์โหลดทุกไฟล์ ปัญหาคือตรงนี้อ่ะค่ะ ทำไง
ให้มันขึ้นว่าดาวน์โหลดทุกไฟล์ พอจะมีวิธีอื่นมั้ยคะ มือใหม่จริง ๆ ค่ะ
ขอบคุณค่ะ
|
 |
 |
 |
 |
Date :
2010-08-26 19:29:50 |
By :
Nutty |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยแนะหน่อยค่ะ ทั้งวันแล้ว ตันจริง ๆ
|
 |
 |
 |
 |
Date :
2010-08-26 23:38:54 |
By :
Nutty |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เวลาดาวน์โหลด ต้องกดปุ่ม download ก่อนหรือเปล่า ถ้าใช่เขียนตามนี้
Code (PHP)
<?
if($download_file)//เอาไว้บรรทัดบนสุด
{
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=".basename($download_file).";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($download_file));
@readfile(($download_file));
}
$sql="select*from upload where type='$jpg'";
$result=mssql_query($sql);
while($row=mssql_fetch_row($result)){
echo "<a href='?download_file=upload/$row[3]'>download</a>";
echo "<br>";
}
?>
|
 |
 |
 |
 |
Date :
2010-08-27 12:52:53 |
By :
heng |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แยกเป็นดาวน์โหลดทีละไฟล์ไหมคะ ถ้าต้องการดาวน์โหลดทั้งหมดก็ทำเป็น zip file แบบนี้จะดีไหม
|
 |
 |
 |
 |
Date :
2010-08-27 14:54:01 |
By :
ultrasiam |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|