2012-04-04 8 views
3

밀도가 높은 날이 있어야합니다. 나는 이것을 알아낼 수 없다.msi 파일 강제 다운로드

내 웹 사이트에 msi 파일을 강제로 다운로드해야하는 페이지가 있지만 다운로드 지침과 함께 페이지의 HTML을 남기고 싶습니다.

지금까지, 나는 HTML에서 다음 태그를 시도
<meta http-equiv="Refresh" content="0; URL=file.msi"> 

그러나 파이어 폭스에서이 깨진 텍스트로 이진 파일을 보여 주었다 (I는이 페이지의 본문에 액세스 할 수 있습니다).

는 다음 나는 그러나이 탭/창을 닫고 설치 지침을 떠나지 않을 다음과 같은 PHP는
$file = "file.msi"; 
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: 5'); 
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; 

을 삽입했습니다.

<META HTTP-EQUIV="Content-Type" CONTENT="application/octet-stream"> 
<meta http-equiv="content-disposition" content="attachment; filename=file.msi" /> 

을하지만이 파일을 다운로드하는 것을 거부 :

마지막으로, 나는 시도 다시 HTML에서 다음과 같습니다. 모든 포인터가 크게 감사하겠습니다.

+0

아래 답변을 참조하십시오. – Whymarrh

답변

0

<meta> 태그는 삽입 된 페이지에 적용되며 파일 다운로드 방식은 변경되지 않습니다. 완전히 다른 페이지로 간주됩니다.

<a href="downloadmsi.php" target="_new" />download</a>과 같은 것이 있어야 지침 페이지와 다른 창에서 다운로드 할 수 있습니다. 당신이 다음을 추가 할 수있는 .htaccess 파일을 사용하고 싶다면

0

, 아파치를 가정 :

AddType application/octet-stream .msi 

this source 당으로. 그런 다음 파일에 링크 만 할 수 있습니다.

0

나는 다운로드 할 .msi를 지정하는 PHP 파일을 만드는 데 도움이되는 this link을 발견했습니다. 처음으로 일했습니다. 어쩌면

가시 다운로드 페이지, downloads.php, href가 위에서

<a href="/downloads/?version=App.Installer.msi">download now</a> 

끊어 처리 페이지, 즉 example.com/downloads/index.php

$root = realpath($_SERVER["DOCUMENT_ROOT"]); 
$file_dl = $_GET['version']; 
header('Content-disposition: attachment; filename='.$file_dl); 
header('Content-type: application/x-ole-storage'); 
readfile($root.'/downloads/'.$file_dl); 

또한, 확실하지 그것을 경우 필요했지만, .htaccess 파일에 다음을 추가했습니다. Marc B