Reputation: 71
I'm trying to store images in storage also that image name in database.
$file = $request->file('attachments');
Storage::disk('public')->put('images',$file);
$attachments = new Attachment();
$attachments->title = $title;
$attachments->path = "NAME OF IMAGE THAT ALREADY STORED ($FILE)";
$inbox_attachments->save();
Example of image name is
5MgomzwHmMxUhKqRu7T4SMhjvfrWtdKLArBSc3bI.jpg
Upvotes: 1
Views: 319
Reputation: 11636
Use basename:
basename — Returns trailing name component of path
Try this:
$storagePath = Storage::disk('public')->put('images',$file);
$attachments->path = basename($storagePath);
Upvotes: 2