1. <?php
  2.   // http://localhost/testphp/22.php?filename=download1.txt
  3.   
  4.   $filedir = "../../data/";
  5.   $file = $filedir.$_GET['filename'];
  6.   
  7.   if (file_exists($file)) {
  8.     header('Content-Description: File Transfer');
  9.     header('Content-Type: application/octet-stream');
  10.     header('Content-Disposition: attachment; filename='.basename($file));
  11.     header('Content-Transfer-Encoding: binary');
  12.     header('Expires: 0');
  13.     header('Cache-Control: must-revalidate');
  14.     header('Pragma: public');
  15.     header('Content-Length: ' . filesize($file));
  16.     ob_clean();
  17.     flush();
  18.     readfile($file);
  19.     exit;
  20.   }
  21. ?>

--------------------------------------------------------------------------------------------


업로드 기능을 작성하여 간단하게 되는 다운로드 기능을 작성해봤습니다.


기본단계2문법에 업로드 기능으로 올린 파일을 GET방식으로 파라미터 보내면

다운로드 받게 작성된 겁니다.

http://roydest.tistory.com/207 대응하는 다운로드임

:
BLOG main image

공지사항

카테고리

분류 (356)
main (1)
php5 (218)
HTML (36)
javascript (93)
IT 이론과 퍼온정보 (8)
깨작일상 (0)
곧 추가할 내용 (0)
추후 알아볼것들... (0)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

달력

«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Total :
Today : Yesterday :