我将文件上传到数据库并使用“php artisan storage:link”创建了存储链接,一切正常,但是当我想下载文件时,我遇到了这个错误
这是我的代码
路线
Route::get('/download/{id}', [\App\Http\Controllers\SubjectController::class, 'downloadFile'])->name('subject.download');
Vue.js
<inertia-link :href="'/download/'+slide.id" class="rounded-lg bg-gray-200 px-4 py-1">
<Icon name="download"></Icon>
</inertia-link>
控制器
public function downloadFile($id) {
$file = Upload::find($id);
$subjectCode = $file->subject()->get()->map->only('name','code')->first()['code'];
$subjectName = $file->subject()->get()->map->only('name','code')->first()['name'];
return response()->download(storage_path('app/public/documents/'.Str::upper($subjectCode.'_'.$subjectName).'/'.$file->file), 'public');
}