Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将上载文件的名称更改为s3_Php_Laravel 5_Amazon S3 - Fatal编程技术网

Php 将上载文件的名称更改为s3

Php 将上载文件的名称更改为s3,php,laravel-5,amazon-s3,Php,Laravel 5,Amazon S3,我使用下面的代码将映像存储到S3磁盘。但是使用这段代码,我得到了一个随机的名字,即我上传的图像的文件名。那么,如何在上传时设置$request->renter\u-proof的文件名?有人请帮忙 $storagePath = Storage::disk('s3') ->put('/company/'.Auth::user()->company.'/renter-proof/', $request->renter_proof, 'p

我使用下面的代码将映像存储到S3磁盘。但是使用这段代码,我得到了一个随机的名字,即我上传的图像的文件名。那么,如何在上传时设置
$request->renter\u-proof
的文件名?有人请帮忙

$storagePath = Storage::disk('s3')
    ->put('/company/'.Auth::user()->company.'/renter-proof/',
          $request->renter_proof,
          'public');
我希望文件名为:

$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');