我可能只是盯着这个太久而且正好在我面前。我正在尝试上传PDF文档。当我这样做时,上传到/storage/resumes/{hash}.pdf/{hash}.pdf而不是/ storage / resumes / {hash} .pdf
它创建了一个与文件同名的额外文件夹。
public function update(Request $request)
{
$user = Auth::user();
$this->validate($request, ['resume' => 'required|mimes:pdf|max:2048']);
$file = $request->file('resume');
$path = $file->hashName('resumes');
$disk = Storage::disk('public');
$disk->put($path, $file);
$oldResumeUrl = $user->resume;
$user->forceFill(['resume' => $disk->url($path)])->save();
if (preg_match('/resumes\/(.*)$/', $oldResumeUrl, $matches)) {
$disk->delete('resumes/'.$matches[1]);
}
$request->user()->forceFill([
'resume' => $request->resume,
'resume_updated_at' => Carbon::now()
])->save();
}
我做错了什么?