如何在Laravel 5.5中将文件名重命名为created_
如何将文件名保存到创建的位置?请帮忙如何在Laravel 5.5中将文件名重命名为created_,laravel,Laravel,如何将文件名保存到创建的位置?请帮忙 $fileName = $file->hashName(); $destinationPath = config('app.filesDestinationPath').'/'.$fileName; $uploaded = Storage::put($destinationPath,file_get_contents($file->getRealPath())); 如果要创建文件名作为时间戳,请使
$fileName = $file->hashName();
$destinationPath = config('app.filesDestinationPath').'/'.$fileName;
$uploaded = Storage::put($destinationPath,file_get_contents($file->getRealPath()));
如果要创建文件名作为时间戳,请使用:
$fileName = $file->hashName();
$destinationPath = config('app.filesDestinationPath').'/'.$fileName;
$uploaded = Storage::put($destinationPath,file_get_contents($file->getRealPath()));
如果您想使用另一种格式,在Laravel 5.5中,您可以执行以下操作:
$fileName = $file->hashName();
$destinationPath = config('app.filesDestinationPath').'/'.$fileName;
$uploaded = Storage::put($destinationPath,file_get_contents($file->getRealPath()));
$fileNmae = now()->format('Y-m-d-H-i-s');
我假设您要重命名的是
$fileName
,使用语法重命名(oldname,newname,context)
您可以简单地执行类似$oldname=$fileName
的操作,并让$newname
在处为您创建所需的以便您最终可以重命名($oldname,$newname)
1515573465这是unix时间戳。您可以使用Carbon::createFromTimestamp()
阅读它。如果要使用可读格式,请使用第二种方法。
$fileName = $file->hashName();
$destinationPath = config('app.filesDestinationPath').'/'.$fileName;
$uploaded = Storage::put($destinationPath,file_get_contents($file->getRealPath()));