php 다운로드 소스 채택완료
#파일 강제 다운로드 헤더 $FileName = "파일명"; $File = "파일이 위치한경로".$FileName;
if(is_file($File)){ //실제로 파일이 있다면 다운로드 수행 if (eregi("MSIE", $HTTP_USER_AGENT)){ header("Content-type: application/octet-stream"); header("Content-Length: ".filesize("$File")); //파일경로 header("Content-Disposition: attachment; filename=$FileName"); //다운로드창에보여질실제파일명 header("Content-Transfer-Encoding: binary"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); // 바로 열기 가능하게 header("Pragma: public"); header("Expires: 0"); }else{ header("Content-type: file/unknown"); header("Content-Length: ".filesize("$File")); header("Content-Disposition: attachment; filename=$FileName"); header("Content-Description: PHP3 Generated Data"); header("Pragma: no-cache"); header("Expires: 0"); } $fp = fopen($File, "rb"); if(fpassthru($fp)){ // 다운로드가 완료되면 //여기에서 다운로드 카운트를 올리면 됨다.(필요없으면 안해도 됨) }else{ fclose($fp); } }else{ // 파일이 없는 경우 echo "파일이 존재하지 않습니다."; // 단순히 처리 했습니다만, 알아서 처리하시면 될것으로 생각됩니다.(필요 없다면 생략!) }
php 다운로드 소스를 찾다보다가 수많은 소스 중에 이것만 적용이 되더라구요..
근데 특정 파일만 다운로드가 되니 ㅠㅠㅠㅠ 하.. 혹시 다수의 파일을 다운로드 할려면 어떻게 해야할까요??
이런식으로요.. 부탁드립니다 ㅠㅠㅠ 이것때문에 밤새고 있네요 하흐
답변 1개
답변을 작성하려면 로그인이 필요합니다.
로그인