0
我试图在用户点击路由时下载文件,并且我能够这样做。但是,当用户想要下载docx或doc文件时,文件扩展名不包含.doc。为了更好地问我的问题,我的代码如下:如何指定下载文件的扩展名Laravel 5.0
Route::get('resumeDownload', function() {
$user = Auth::user();
$path = $user->cv()->first()->path; //when the user uploads a document, i store
//the path of it in the database
$extension = explode(".", $path)[1]; //if the user uploaded a doc, returns .doc etc
$uploaded = Storage::get($path); //I get it from my storage
return (new \Illuminate\Http\Response($uploaded, 200))
->header('Content-Type', 'application/pdf');
});
此代码的工作,当用户想要下载一个PDF伟大的,但是,对于一个.doc文件或.docx文件,这是下载的文件有没有延期。如果可以提供帮助,我还可以保存扩展名并轻松检索。无论如何要为.doc,.docx,.pdf和.txt做这项工作吗?
你能告诉我如何从我的代码获得$ fileContent请? – Muhammad
file_get_contents($ path) –