我试图将图像存储在数据库中的图像名称存储中。
$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();
图片名称示例为
5MgomzwHmMxUhKqRu7T4SMhjvfrWtdKLArBSc3bI.jpg
答案 0 :(得分:2)
使用basename:
basename - 返回路径的尾随名称组件
试试这个:
$storagePath = Storage::disk('public')->put('images',$file);
$attachments->path = basename($storagePath);