2010-03-27 5 views
1

이제이 코드를 얻었습니다.다운로드 상자가 나타나면 어떻게 페이지를 리디렉션 할 수 있습니까?

<?php 

$file = "pain.png"; 

if (file_exists($file)) { 
    header('Content-Description: File Transfer'); 
    header('Content-Type: application/octet-stream'); 
    header('Content-Disposition: attachment; filename='.basename($file)); 
    header('Content-Transfer-Encoding: binary'); 
    header('Expires: 0'); 
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 
    header('Pragma: public'); 
    header('Content-Length: ' . filesize($file)); 
    ob_clean(); 
    flush(); 
    readfile($file); 
    exit; 
} 
?> 

이 코드는 다운로드 상자에 표시됩니다. 하지만이 페이지를 "감사합니다"페이지로 리디렉션하고 싶습니다. 여기에도 다운로드 상자가 있습니다. 내가 어떻게 할 수 있니?

감사합니다 ...

답변

0

다운로드 는 HTTP 응답이이기 때문에, 당신은 다운로드 응답 내에서 그것을 할 수 없습니다. 당신은 그들을 리디렉션하고 다음 "감사합니다, 다운로드가 지금 일어날 것입니다"등 등이 표준 솔루션 대부분의 장소 것 같습니다.

감사 페이지에서 다운로드 URL로 리디렉션됩니다.

2

당신은

당신은 같은 다운로드 페이지에 홈페이지에서 링크 할이 사용하는 메타 새로 고침 (http://en.wikipedia.org/wiki/Meta_refresh)을 수행 할 수 있습니다.

index.html을

<html><head></head><body> 
Download my awesome <a href="download.html">file</a> 
</body></html> 

인 download.html

<html> 
     <head> 
     <meta http-equiv="refresh" content="0;url=http://example.com/download.php" /> 
     </head> 
     <body> 
     Thanks for choosing Foobar! Your download will begin shortly. 
    If you're download does not begin, 
click <a href="http://www.example.com/download.php">here</a> 
     </body> 
     </html> 
관련 문제