0

共有ホスティングを使用しているため、Apache の設定を編集できません。ユーザーが次の方法で .crx ファイルをダウンロードできるようにする必要があります。

1) The file has the content type application/x-chrome-extension
2) The file is not served with the HTTP header X-Content-Type-Options: nosniff
3) The file is served with one of the following content types:
- empty string
- "text/plain"
- "application/octet-stream"
- "unknown/unknown"
- "application/unknown"

PHPまたは他の方法でこれを行うにはどうすればよいですか?

4

5 に答える 5

1

次の行を追加してみてください。

AddType application/x-chrome-extension crx

.htaccess ファイルに。

于 2012-05-24T14:02:57.987 に答える
1
<?php
header("Content-Type: application/x-chrome-extension; charset=UTF-8");   // use here both proper settings for your case
//  header("Content-Length: " .filesize($your_crx_file));    // this is realy optional, I do recomend to not include this sentence
header('Content-Disposition: attachment; filename="TheNameThatYouWant.crx"');    // this set the name of the downloaded file on browser side.
readfile($your_crx_file)
?>
于 2012-05-24T13:45:59.500 に答える
1

関数を使用header()します。

header('Content-Type: text/plain');

アップデート:

申し訳ありませんが、ファイルが.crxであることを忘れていました:)

ファイルがcool_app.crxの場合、次のようにラッパーを記述しますcool_app.php

<?php
header('Content-Type: application/x-chrome-extension');
include 'cool_app.crx';

次に、リンクを に向けcool_app.phpます。

于 2012-05-24T13:21:09.837 に答える
0

私のコメントによると:

header('content-type: text/plain'); // set the content-type
readfile('path-to-crx.crx');

まず、関数を使用してコンテンツタイプを設定しheaderます。

次に、ファイルがサーバーに存在する場合は、このreadfileメソッドを使用してファイルを送信するか、実行中に生成された場合は、ファイルの内容をエコーし​​ます。

于 2012-05-24T13:31:02.080 に答える
0

これはうまくいきます

<?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;
}
?>
于 2013-05-12T20:29:44.263 に答える