dongtangxi1584 2017-01-23 13:29
浏览 903

在iOs谷歌浏览器上下载文件时出现问题

I'm trying to force download a .zip archive using PHP code below:

$filePath = BASE_PATH . '/uploads' . $product->mainFile;

header('Pragma: public');
header('Expires: 0');
header('Cache-Control: no-cache');                                      
header('Content-Description: Download'); 
header('Content-Type: application/octet-stream'); 
header('Content-Disposition: attachment; filename="crazypatterns_' . $product->id . '.zip"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.filesize($filePath));

This code works fine on all browsers and devices... except google chrome on iOs. When trying to download archive, on download page - an error occurs: "Cannot determine file size". Archive name is incorect and displays as 'login', and when download this file, filesize is determined incorrectly - 20-30KB, although it's real size is over 10MB. Screenshot with error occured - http://imgur.com/a/1Gr1L .

P.S. $filePath variable is correct, and given archive exists. Thanks ;)

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 高德地图点聚合中Marker的位置无法实时更新
    • ¥15 DIFY API Endpoint 问题。
    • ¥20 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办