Level 6
$name = $file->getClientOriginalName();
$path = 'public/images';
...
$post->name = $request->name; // here you should use $path . '/' . $name instead
Using the below code, it should upload to the path specified in $path but for some reason, it saves the links to all pictures to c:\xampp\tmp with the .tmp extension but will move them to the correct folder anyway. What have I done wrong?
public function store(Request $request){
//
if($file = $request->file('image')){
$name = $file->getClientOriginalName();
$path = 'public/images';
if($file->move($path, $name)){
$post = new Gallery();
$post->image = $request->image;
$post->name = $request->name;
$post->species_id = $request->species_id;
$post->tag = $request->tag;
$post->patreon = $request->tag;
$post->save();
return redirect()->route('admin.gallery.index');
};
};
}
$post->name = $path . '/' . $name;
because in $request->name is still the temp-name.
Please or to participate in this conversation.