我没有运气从我的在线商店提供 .dmg。我将代码简化为以下代码以进行调试,但无论我得到一个零字节文件是什么:
header('Content-Type: application/x-apple-diskimage'); // also tried octet-stream
header('Content-Disposition: attachment; filename="My Cool Image.dmg"');
$size = filesize('/var/www/mypath/My Cool Image.dmg');
header('Content-Length: '.$size);
readfile('/var/www/mypath/My Cool Image.dmg');
相同的代码适用于我提供的许多其他文件类型:bin、zip、pdf。有什么建议么?谷歌教授不是我的朋友。