2012-02-11 2 views
0

이미지 다운로드가 작동하지 않습니다. 그것은 직접 다운로드하지 읽습니다.이미지 다운로드가 작동하지 않습니다. 그것은 바로 읽기

if($_REQUEST['image'] == true){ 

    $URl = $post->guid; 
    echo $URl; 
    header("Content-Type: image/png"); 
    header('Content-Description: File Transfer'); 
    header("Cache-Control: no-cache, validated"); 
    header('Content-Type: application/octet-stream'); 
    header("Content-Disposition: attachment; filename=\"".basename($URl)."\""); 
    header('Content-Transfer-Encoding: binary'); 
    var_dump(readfile($URl)); 
    die; 
} 
+0

는 [변수는 대소 문자를 구분 (http://php.net/manual/en/language.variables.basics.php). '$ URl'을'$ URL'로 변경하십시오 (Ls?에 주목하십시오). – Josh

+0

나는 그랬지만 작동하지 않았다. ... – ayyan

+0

"작동하지 않는 것"은 무엇인가? – zerkms

답변

0

이 헤더 포맷을 시도

header("Content-type: application/octet-stream"); 
header("Content-Length: " . filesize($filename)); 
header("Content-Disposition: attachment; filename=$filename"); 
header('Content-Transfer-Encoding: binary'); 
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 
fpassthru($fp); 
+0

Avinash 나는 바꿉니다. 그러나 이제는 똑같은 출력이 이미지를 직접 읽지 못해서 다운로드하지 않습니다 ...... – ayyan

+0

콘텐츠 유형을 "application/octet-stream"으로 업데이트하십시오. 당신이 팝업 상자를 보장 할 수 없기 때문에, 그것은 클라이언트의 browsing 소프트웨어가 그 paticular mime-type으로 어떻게하고 싶은지에 달려 있습니다. – Avinash

+1

이미지를 zip 파일에 링크하면 다운로드됩니다. –

관련 문제