Laravel Response Download返回一个字符串

时间:2018-11-21 09:12:44

标签: excel laravel laravel-5 response

如标题中所述,我正在生成XLSX文件并将其保存到public / reports / $ filename中。 Excel文件生成的很好,这里没有问题。问题是一旦我尝试下载它,它就会返回一个字符串,如下所示:

// This generates the Excel file and save it to the disk and returns the file name
$report = Report::generateReport($request->type, $request->from, $request->to);

// This is the file path.
$filePath = public_path() . '/reports/' . $report;

return \response()->download($filePath, $report, [
        'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    ]);

以及我得到的答复:

UEsDBBQAAAAIABpIdU1HkkSyWAEAAPAEAAATAAAAW0NvbnRlbnRfVHlwZXNdLnhtbK2UTU7DMBCF95wi8hYlblkghJp2QWEJlSgHMPakserYlmf6d3smaQsIiUDVbmJF9nvf+Hns0WTbuGwNCW3wpRgWA5GB18FYvyjF2/wpvxMZkvJGueChFDtAMRlfjea7CJix2GMpaqJ4LyXqGhqFRYjgeaYKqVHEv2kho9JLtQB5MxjcSh08gaecWg8xHr0wP1kD2UwlelYNY+TWSWI32H+HBfuJ7GEvbNmlUDE6qxVx4XLtzQ9qHqrKajBBrxqWFJ3NdesifwUi7Rzg2SiMCZTBGoAaV+xNj+QpVGrlKHvcsvs+8wQOT+MdwixY2a3B2sY+Qv+GftetzwyC9dOkNtxKPaFvQlq+h7C8dOztWDTK+r5DZ/EshYiSUWcXAG1yBkwe2RIS2a9j72XrkOB0+LEJWvU/iYe0u2hQdsPwwrF/+v911WqVwLxS4ua4+I377n2sQ3YP1vgDUEsDBBQAAAAIABpIdU0Xtjc46QAAAEsCAAALAAAAX3JlbHMvLnJlbHOtks1qwzAMgO97CqN7o7SFMUadXsqgtzKyB9Bs5YcklrG9LX37eYexBbrSw46WpU+fhHb7eRrVO4fYi9OwLkpQ7IzY3rUaXuqn1QOomMhZGsWxhjNH2Fd3u2ceKeWa2PU+qgxxUUOXkn9EjKbjiWIhnl3+aSRMlPIztOjJDNQybsryHsNvBlQLpjpaDeFot6Dqs+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BIwcAAHhsL3RoZW1lL3RoZW1lMS54bWxQSwECFAMUAAAACAAaSHVNjxrLVCkBAAB1AgAAFAAAAAAAAAAAAAAAtoEHDQAAeGwvc2hhcmVkU3RyaW5ncy54bWxQSwECFAMUAAAACAAaSHVN4l+c3vkBAABoBAAADQAAAAAAAAAAAAAAtoFiDgAAeGwvc3R5bGVzLnhtbFBLAQIUAxQAAAAIABpIdU1c7u0urAEAAPUCAAAPAAAAAAAAAAAAAAC2gYYQAAB4bC93b3JrYm9vay54bWxQSwECFAMUAAAACAAaSHVN5KdUL6wDAAD2CgAAGAAAAAAAAAAAAAAAtoFfEgAAeGwvd29ya3NoZWV0cy9zaGVldDEueG1sUEsBAhQDFAAAAAgAGkh1Tc1LUiJ4AAAAjQAAACMAAAAAAAAAAAAAALaBQRYAAHhsL3dvcmtzaGVldHMvX3JlbHMvc2hlZXQxLnhtbC5yZWxzUEsFBgAAAAALAAsA0QIAAPoWAAAAAA==

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:0)

通过向文件本身添加额外的AJAX get请求解决了该问题。无法找到其他解决方案。