PHP强制下载.app文件?

PHP强制下载.app文件?,php,Php,我正在尝试强制下载.app文件 尝试了以下操作,但只是给了我一个空的.app文件: <?php header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=Application.app"); header("Content-Type: application/z

我正在尝试强制下载.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");

?>
替换

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

然后用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

在末尾添加此行:

readfile('Application.app');
因为您没有输出文件内容

<?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"); ?>

代码的其余部分在哪里?输出数据了吗?这里有一堆标题,但实际上并没有将文件发送到浏览器。看到你的文件0字节了吗?你说这些都不行。所以要么你对我们隐藏了一些东西,要么Application.app是0字节。Application.app是一个Mac OS应用程序文件以及目录,我猜你不能强制只下载目录文件。事实上,.app文件在某些情况下是.zip文件。他想强制下载。一旦你下载了标题就不再重要了。我猜如果浏览器像IE一样愚蠢,它会告诉你它是一个zip,并将其重命名为.zip-_-添加了两个,但仍然是0字节:/@Alosyius请确保您的文件实际上不是空的。并且您将其所在位置的路径放在readfile上。仍然存在相同的问题,文件为0字节:/n如果该文件甚至被称为Application.app?该文件是否包含任何信息?
<?php header("Location: http://example.com/application.app"); ?>