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

我正在尝试使用以下PHP代码强制下载.zip存档:</ p>

  $ filePath = BASE_PATH。  '/ uploads'。  $ product-&gt; 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-&gt; id。'。zip”');
header('Content-Transfer-Encoding:binary');
header('Content- 长度:'。filesize($ filePath));
</ code> </ pre>

此代码适用于所有浏览器和设备...除了iOs上的谷歌浏览器。

当试图下载存档时,在下载页面上会发生错误:“无法确定文件大小”。 存档名称是incorect并显示为'login',当下载此文件时,filesize被错误地确定 - 20-30KB,虽然它的实际大小超过10MB。
有关错误的屏幕截图 - http://imgur.com/a/1Gr1L 。</ p>

PS $ filePath变量是正确的,并且存在给定的存档。
谢谢;)</ p>
</ div>

展开原文

原文

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

doudie2693
doudie2693 嗨你找到了解决方案吗?
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐