PHP 检索文件到平板电脑失败
我们的系统将用户上传的文件存储在网络根目录之上,文件名存储在数据库中。当用户想要下载时,他们单击文件名,我们的下载器页面使用以下内容获取文件...
header('Content-Type: '.$mime);
header('Content-Disposition: attachment; filename="'.$filename.'"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.sprintf('%d', $filesize));
header('Expires: 0');
// check for IE only headers
if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) {
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
} else {
header('Pragma: no-cache');
}
$handle = fopen($filepath, 'rb');
fpassthru($handle);
fclose($handle);
它现在似乎适用于所有浏览器,但当我们尝试从 iOS 或 Android 设备上时,没有任何反应。希望有人能看到我错过的明显的东西。我是手持/平板设备开发的新手。
谢谢
Our system stores files a user uploads above the webroot, with the filename getting stored in the DB. When a user wants to download, they click the filename, and our downloader page gets the file using the following...
header('Content-Type: '.$mime);
header('Content-Disposition: attachment; filename="'.$filename.'"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.sprintf('%d', $filesize));
header('Expires: 0');
// check for IE only headers
if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) {
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
} else {
header('Pragma: no-cache');
}
$handle = fopen($filepath, 'rb');
fpassthru($handle);
fclose($handle);
It seems to work in all browsers now, but when we try from iOS or Android devices, nothing happens. Hoping someone will see something obvious I've missed. I'm new to developing for handheld/tablet devices.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以检查一下
而不是提供 mime 类型。
You could check
instead of providing mime type.