I have probably just been staring at this too long and its right in front of me. I am trying to upload PDF documents. When I do it uploads to /storage/resumes/{hash}.pdf/{hash}.pdf
Its creating an extra folder with the same name as the file.
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();
}
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2A6NWXr
via IFTTT
Aucun commentaire:
Enregistrer un commentaire