php - 如何下载大于 12 MB 的 PDF 文件?
问题描述
当下载大于 12 MB 的文件时,我在 php 中下载文件时遇到问题,但成功下载了小于 12 MB 的文件。这是我的代码:
if(isset($_REQUEST["file"])){
$file = urldecode($_REQUEST["file"]); // Decode URL-encoded string
if(file_exists($file)) {
$fp = fopen($file, "rb");
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Content-Transfer-Encoding: binary');
header('Connection: Keep-Alive');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header("Cache-Control: public");
header('Pragma: public');
header('Content-Length: ' . filesize($file));
set_time_limit(0);
readfile($file);
ob_end_clean();
die(fpassthru($fp));
fclose($fp);
exit;
}
}
问题已解决。只需删除文件名的符号字符。
解决方案
推荐阅读
- r - Sprintf showing few arguments
- r - 如何评估嵌套列表中的表达式
- ruby-on-rails - 如何将字符串中的每个 2 个单词拆分为数组 - Ruby?
- jdbc - kafka-connect-jdbc 新连接器阻止旧连接器
- ios - 在 ios 上更改 expo-camera 或 RNCamera 的纵横比
- c# - 如何将 webelement 的页面位置转换为它的屏幕位置?
- c++ - 在 C++ 中的本地 _RecordsetPtr 中复制记录集
- python - 不同的查询集,相同的结果
- r - 在R中调整图表中的线
- javascript - 以与搜索功能请求相同的顺序获取 axios 响应