繁体   English   中英

如何获取存储在存储中的图像的路径或名称?

[英]How to get path or name of image that store in Storage?

我正在尝试将图像存储在存储中,并将图像名称存储在数据库中。

$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

使用基本名称

basename — 返回路径的尾随名称部分

尝试这个:

$storagePath = Storage::disk('public')->put('images',$file);

$attachments->path = basename($storagePath);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM