I think it's because you're using the $request to create your new Platform entity. At this time the image isn't stored and resides in your /tmp folder.
So store it first and then use the stored image for your Platform::create().
Hello friends.
I want to build a simple upload.
First I create a request file. There I define the rules.
public function rules()
{
return [
'title' => 'required',
'link' => 'required',
'image' => 'required',
];
}
Now the controller...
public function store(StorePlatformRequest $request)
{
Platform::create($request->validated());
$newImageName = time() . '-' . $request->title . '.' . $request->image->extension();
$request->image->move(public_path('img'), $newImageName);
return redirect()->route('dashboard');
}
The problem is that it saves me the path "/tmp/phpVLn6qr" in the database.
It is the wrong directory, with the wrong name and without extension. What exactly am I doing wrong?
How do you know that?
The file will be in storage/app/public folder.
Start reading a documentation
Please or to participate in this conversation.