-5

我正在尝试强制下载 .app 文件..

尝试了以下,但它只是给了我一个空的 .app 文件:

<?php
    header("Cache-Control: public");
    header("Content-Description: File Transfer");
    header("Content-Disposition: attachment; filename=Application.app");
    header("Content-Type: application/zip");
    header("Content-Transfer-Encoding: binary");

?>
4

3 回答 3

1

代替

header("Content-Type: application/zip");

header("Content-Type: application/octet-stream");

然后用 ie 输出你的文件readfile()。而且我还建议摆脱?>标签。所以应该是:

<?php
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=Application.app");
header("Content-Type: application/zip");
header("Content-Transfer-Encoding: binary");

readfile('Application.app');     // replace Application.app with right filename or full path to subject file
于 2013-07-25T19:03:48.317 回答
0
<?php
$file = "http://example.com/application.app"; 

header("Content-Description: File Transfer"); 
header("Content-Type: application/zip");  // proper octet-stream
header("Content-Disposition: attachment; filename=\"$file\""); 

readfile ($file); 
?>

如果文件没有用浏览器打开..

<?php header("Location: http://example.com/application.app"); ?>
于 2013-07-25T19:10:52.580 回答
0

在最后添加这一行:

readfile('Application.app');

因为您没有输出文件内容。

于 2013-07-25T19:04:55.537 回答