在Laravel 4.2中强制下载.xls文件

我有以下路线:

Route::get('/download/{id}/{filename}', function($id, $filename) { // Check if file exists in app/storage/file folder $file_path = storage_path() .'/orders/'.'/'.$id.'/'. $filename; if (file_exists($file_path)) { // Send Download return Response::download($file_path, $filename, [ 'Content-Type: application/vnd.ms-excel; charset=utf-8' ]); } else { // Error exit('Requested file does not exist on our server!'); } })->where('filename', '[A-Za-z0-9\-\_\.]+'); 

在Laravel下载一个excel文件格式/应用程序/存储(以前上传)。 我面临的问题是,下载的Excel文件是由Excel无法读取的。 如果我从FTP下载上传的文件没关系。 我尝试了Content-Type的所有types的头文件,但似乎没有任何工作。 是否有一个特殊的Excel文件头? 非常感谢。

我在CI中使用这个代码请findLaravel的帮助文件或库

 $this->load->helper('download'); if(file_exists("user_files/test.txt")){ $data = file_get_contents("user_files/test.txt"); force_download("test.txt", $data); }else{ echo "Error"; }