S o f t G a n z.

Web & Software Developer Gang.

Download file with PHP

by Little Bear @February,23 2008 09.23 ( IP : 61...220 )

Example PHP code for download file that nobody know your file url

ตัวอย่าง code สำหรับดาวน์โหลดไฟล์โดยไม่ให้ใครรู้ url ของไฟล์ที่กำลังดาวน์โหลด

<?php
define('DOCUMENT_FOLDER','docs/');

// add .pdf file extension $filename=$_GET['file'].'.pdf';

$body='

Download file '.$filename.'

';

// get filename to download from DOCUMENTFOLDER or select from database $file=DOCUMENTFOLDER.$filename;

$body.='

Start downloading file '.$filename.'

';

if (fileexists($file) && isfile($file)) { header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename="'.$filename.'"'); readfile($file); } else { $body.='

Download file '.$filename.' not found.

'; } echo ' Download '.$body.' '; ?>

แสดงความคิดเห็น

« 9225
หากท่านไม่ได้เป็นสมาชิก ท่านจำเป็นต้องป้อนตัวอักษรของ Anti-spam word ในช่องข้างบนให้ถูกต้อง
The content of this field is kept private and will not be shown publicly. This mail use for contact via email when someone want to contact you.
Bold Italic Underline Left Center Right Ordered List Bulleted List Horizontal Rule Page break Hyperlink Text Color :) Quote
คำแนะนำ : เนื่องจากได้มีการเปลี่ยนแปลงวิธีการขึ้นบรรทัดใหม่ ซึ่งมีรายละเอียดดังนี้
  • วิธีการขึ้นบรรทัดใหม่โดยไม่เว้นช่องว่างระหว่างบรรทัด ให้เคาะเว้นวรรค (Space bar) ที่ท้ายบรรทัดจำนวนหนึ่งครั้ง
  • วิธีการขึ้นย่อหน้าใหม่ซึ่งจะมีการเว้นช่องว่างห่างจากบรรทัดด้านบนเล็กน้อย ให้เคาะ Enter จำนวน 2 ครั้ง

Member Zone

Playing