下载 zip 文件会在提取后生成 .cpgz 文件

Downloading zip file results in .cpgz file after extraction

我正在使用以下代码下载一个 zip 文件。我确定该文件存在并且在服务器上工作。结果是提取后的.cpgz文件。

  return response()->download('/Applications/XAMPP/xamppfiles/htdocs/stoproject/source/storage/app/Copy of StoTherm Classic®.zip');

代码正常运行,没有任何更改,它停止了。

我也尝试添加 headers:

$headers = array(
            'Content-Type' => 'application/zip',
        );

return response()->download('/Applications/XAMPP/xamppfiles/htdocs/stoproject/source/storage/app/Copy of StoTherm Classic®.zip', basename('/Applications/XAMPP/xamppfiles/htdocs/stoproject/source/storage/app/Copy of StoTherm Classic®.zip'), $headers);

也试过:

'Content-Type' => 'application/octet-stream'

调用 ob_end_clean() 解决了问题

$response = response()->download($pathToFile)->deleteFileAfterSend(true);

ob_end_clean();

return $response;

Laravel 4 Response download issue