php - Change name of uploading file into s3
问题描述
I use the below code to store an image to my S3 disk. But using this code i get a random name i.e filename to the image that I'm uploading. So how can i set the filename of $request->renter_proof
while uploading? Someone please help.
$storagePath = Storage::disk('s3')
->put('/company/'.Auth::user()->company.'/renter-proof/',
$request->renter_proof,
'public');
I want the name of the file to be :
$imageName = 'Tag '.$request->input('stock_on_rent').'.'.$request->renter_proof->getClientOriginalExtension();
解决方案
解决方案是使用putFileAs()
我使用了以下代码:
$path = "/company/".Auth::user()->company."/renter-proof";
$imageName = 'Tag '.$request->input('stock_on_rent').'.'.$request->renter_proof->getClientOriginalExtension();
$storagePath = Storage::disk('s3')->putFileAs($path,$request->renter_proof,$imageName ,'public');
推荐阅读
- flutter - pushReplacement 后屏幕内容不居中
- .net - 是否可以从 Roslyn Analyzer 访问 appsettings.json?
- javascript - 从数组javascript中删除项目时重新渲染列表的问题
- android - 为什么会有错误 buildozer debug 和 sdl 2?
- python - 具有自定义值的 Pandas DataFrame 映射
- c - Scanf没有编译
- c++ - “过度拥挤”成员初始化列表是一回事吗?
- javascript - 显示图像构建反应
- mysql - #1062 mysql 中的错误
- java - 不登录就无法访问静态资源目录(我使用的是spring security)