在Laravel中,我成功地在存储中上传了文件,并将存储与公共连接。我上传的目录如下,
这是我的下载按钮代码,
<form action="{{route('download', $file->id)}} " method="get">
@csrf
<button type="submit" class="btn border-none btn-sm btn-primary">Download</button>
</form>这是我的路线,
//Download uploaded file
Route::get('/download/{file}', [UploadUserFileController::class, 'downloadfile'])->name('download')->middleware('auth');这是我的控制器代码,
// Download requested file
public function downloadfile($id){
$filelink = File::find($id);
// return Storage::disk('public')->download('./storage/files/'.$filelink->files);
// return Storage::download('./files/'.$filelink->files);
return response()->download('/storage/files/'.$filelink->files, $filelink->files);
}但是在我点击“下载”按钮后,它显示了这个错误,
文件“///Demand.pdf”不存在
我是拉勒维尔的新手,我不了解这个问题。请帮帮我。
发布于 2021-01-30 15:51:38
我知道我的问题,我的表格错了,我把文件传错了方向。
我的问题用这个解决了,
<form action="{{route('download', $file->files)}} " method="get">
@csrf
<button type="submit" class="btn border-none btn-sm btn-primary">Download</button>
</form>https://stackoverflow.com/questions/65968764
复制相似问题