PHP文件下载脚本不适用于iOS7设备吗? [英] php file download script doesn't work with iOS7 device?
本文介绍了PHP文件下载脚本不适用于iOS7设备吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下php脚本来触发自动下载.
I have the follow php script to trigger auto downlad.
<?php
ob_start();
$file = 'sample.jpg';
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
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;
}
?>
它可以在台式机和Android手机上正常运行,但不能在iPad和iPhone上正常运行.
it works properly on desktop and my android phone, but not on my iPad and iPhone.
我应该怎么做才能使其在iPad&iPhone?
what should I do to get it works on iPad & iphone?
谢谢.
推荐答案
尝试注释掉设置Content-Length的行,如下所示:
Try commenting out the line where you set the Content-Length, like this:
//header('Content-Length: ' . filesize($file));
...我没有更深入地研究,但现在在iPad iOS 7.0.4上对我来说有效
... I haven't dug deeper but right now that's working for me on iPad iOS 7.0.4
这篇关于PHP文件下载脚本不适用于iOS7设备吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文