I am trying to upload an image but when i check my public folder the image has a different name and a .tmp extension :
public function store_company(Request $request)
{
$request->validate([
'image' => 'required|image|mimes:jpg,png,jpeg|max:3048'
]);
$name = $request->RS;
$name = preg_replace('/\s+/', '', $name);
$NewLogoName = time() . 'lo-go-' . $name . '.' . $request->image->extension();
$path = $request->image->move(public_path('assets/images' , $NewLogoName));
$company = new entreprise;
$company->RS = $request->RS;
$company->adresse = $request->adresse;
$company->Fax = $request->Fax;
$company->Tel1 = $request->Tel1;
$company->Tel2 = $request->Tel2;
$company->mail = $request->mail;
$company->Logo = $NewLogoName;
$company->save();
return redirect('/Dashboard');
}
please any idea how to solve this !
You moved the temporary file (uploaded file) from the tmp folder to the public folder. since you did not provide a name it kept the tmp filename.
in move()
the second parameter is the new file name and the first one is just the path.
change it to
$path = $request->image->move(public_path('assets/images'), $NewLogoName);