2012-05-24 4 views

답변

6

당신은에있는 경우 및 서버 구성을 변경할 수 없습니다, PHP를 사용하여 호스팅하는 공유 :

<?php 
$file = 'extension.crx'; 

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

source

이 ($file 변수에 의해 지정된) 파일을 강제로 사용자 정의 헤더를 다운로드합니다.

+0

감사합니다. 매우 도움이되었습니다. – zur4ik

+2

기술적 인 관점에서 볼 때 정확하지만 최신 버전의 Chrome에서는 더 이상 작동하지 않습니다. https://support.google.com/chrome_webstore/answer/2664769 – bfncs

1

난 당신이 사용하고있는 웹 서버 모르겠지만, 아파치 다음 수행 할 수 있습니다 파일

  • 다시 시작의 끝에서 application/x-chrome-extension crx :

    1. VI /path/to/your/httpd/conf/mime.types
    2. 이 줄을 추가를 웹 서버 : killall -HUP httpd

    또는 당신은 당신의 .htaccess 파일에 다음 행을 추가하는 시도 할 수 있습니다 :

    AddType application/x-chrome-extension crx 
    

    그리고 제대로 작동합니다.

  • +0

    공유 호스팅을 사용 중이므로 Apache 설정을 편집 할 수 없습니다. PHP에서이 작업을 수행 할 수 있습니까? – xRobot

    +1

    뭔가를 찾았습니다. .htaccess에 Add를 추가 할 수 있습니다. AddType application/x-chrome-extension crx – divaka

    관련 문제