You can use this function
https://www.php.net/manual/fr/function.basename.php
$question->image = basename($path);
Hi!
Im trying to save files from a form. And it seems to work! The files appear in the correct folder as I wish, but another problem has encountered; that the directory name included in when saving to database.
if($path = Storage::putFile('public', $request->file('photo'))){
$question->image = $path;
$question->save();
}else{
return response()->json('failed to upload the image', 500);
}
This results in public/sadasdsdfadf.png but I just want sadasdsdfadf.png to be stored. How can I achieve this?
Please or to participate in this conversation.