I uploaded a file to the database and created Storage link using "php artisan storage:link" and everything work perfectly but when I want to download the file I face this error
这是我的代码
route
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');
}
replace
<inertia-link :href="'/download/'+slide.id" class="rounded-lg bg-gray-200 px-4 py-1">
<Icon name="download"></Icon>
</inertia-link>
to
<a :href="'/download/' + slide.id" class="rounded-lg bg-gray-200 px-4 py-1">
<Icon name="download"></Icon>
</a>
那么它不会处理inertia
它会让你下载文件
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)