【发布时间】:2021-10-14 03:56:32
【问题描述】:
因为我还没有找到解决方案,所以再次发布。
Laravel 找不到文件 storage/app/public/upload
当我使用http://127.0.0.1:8000/storage/upload/The_fileName.x 我得到404 not found
我也试过http://127.0.0.1:8000/storage/app/public/upload/The_fileName.x 。
我该怎么办?
在DocumentController:
public function store(Request $request)
{
$request->validate([
'doc' => "required",...
]);
$document = new document();
$file = $request->file('doc');
$filename=time().'.'.$file->getClientOriginalExtension() ;
// I've tried these too, one by one and still get the same error .
//$file_path = public_path('public/upload');
//$file->move($file_path, $filename);
//Storage::disk('local')->put($file, $filename);
//request('doc')->store('upload', 'public');
$file->storeAs('public/upload', $filename);
$document->doc = $request->input('doc', $filename);
$document->candidate_id = $candidate_id;
$document->save();
提前谢谢你
【问题讨论】:
-
您当前存储在
public/upload,因此URL 路径为http://127.0.0.1:8000/upload/The_fileName.x。The_fileName.x在您的文件系统中的什么位置? -
@aynber 127.0.0.1:8000/upload/The_fileName.x 也不起作用,文件在 (C:\Users\user\Documents\project\storage\app\public\upload)
标签: php laravel file upload laravel-8