PHP 다운로드 오류...

PHP 다운로드 오류...

QA

PHP 다운로드 오류...

본문

?fname=http%3A%2F%2Ffile.okky.kr%2Fimages%2F1451462162182.pnghttp://i1.search.daumcdn.net/s/knowledge4_re/btn_original.png); background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">원본보기


 

이렇게 파일을 다운로드 하려고 시도하면

download.php 가 다운로드됩니다.

아래는 소스코드 입니다. 보시죠.


 

<?php

$filename = 'upload/'."$_GET['file']";

$filename = str_replace( " ","+", $filename ); // 공백문자의 제거(권장)

 $extension = $_GET['type'];


switch($extension) {

case "exe": $type="application/octet-stream"; break;

case "zip": $type="application/zip"; break;

case "gif": $type="image/gif"; break;

case "png": $type="image/png"; break;

case "jpeg":

case "jpg": $type="image/jpg"; break;

case "mp3": $type="audio/mpeg"; break;

case "wav": $type="audio/x-wav"; break;

case "avi": $type="video/x-msvideo"; break;

default: $type="application/force-download";

}

$filepath = $filename;

header("Pragma: public");

header("Expires: 0");

header("Cache-Control: must-revalidate, post-check=0, pre-check=0");

header("Cache-Control: public");

header("Content-Description: File Transfer");

header("Content-Type: ".$type);

header("Content-Disposition: attachment; filename=". basename($filepath) .";");

header("Content-Transfer-Encoding: binary");

header("Content-Length: ".@filesize($filepath));

@readfile($filepath);

 ?>



실제로 다운로드는 잘 되구요.

파일 이름이 저렇게 됩니다.

 

저 파일을 .mp3 으로 변환하면 잘 플레이 됩니다.;;

이 질문에 댓글 쓰기 :

답변 1

header("Content-Disposition: attachment; filename=". basename($filepath) .";");

 

이게 문제인거같아요.


filename은 다운로드될 파일의 이름을 지정해주는건데 여기에 경로까지 다 들어가서 생기는 문제 같아요.

답변을 작성하시기 전에 로그인 해주세요.
전체 123,908 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT