this?
$path = request()->file('image')->store('posts');
try, dd($path), you will see the unique name.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, i love tha simple it is to upload a file in laravel 5.3, i saw the laracast and simply copied the code to upload a file.
request()->store('image')->store('posts');
That makes the magic of uploading the file to the storage but, how do i get back the unique name that laravel gave the image and make the controller update it to the database as that name ?
public function update($id, UpdatePostRequest $request)
{
request()->file('image')->store('posts');
$post = $this->postRepository->findWithoutFail($id);
if (empty($post)) {
Flash::error('Post not found');
return redirect(route('posts.index'));
}
$post = $this->postRepository->update($request->all(), $id);
Flash::success('Post updated successfully.');
return redirect(route('posts.index'));
}
Please or to participate in this conversation.