Laravel文件上传创建文件夹的文件夹

时间:2017-11-26 14:05:14

标签: laravel-5 laravel-5.5

我可能只是盯着这个太久而且正好在我面前。我正在尝试上传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();
 }

我做错了什么?

0 个答案:

没有答案