Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.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
File 使用laravel 5重命名图像_File_Laravel 5_Rename - Fatal编程技术网

File 使用laravel 5重命名图像

File 使用laravel 5重命名图像,file,laravel-5,rename,File,Laravel 5,Rename,我有一个带有图像的目录,我向用户显示,用户可以重命名图像,我有一个带有图像的文件 $images=File::files('img'); $image=$images[0]; 但我不知道如何重命名图像。 谢谢您可以先从输入中检索它。并使用您定义的文件名移动它。 您的图像将使用您指定的文件名显示 $picture= $request->file('image'); $fileName = 'what the image you want to call'; $picture->m

我有一个带有图像的目录,我向用户显示,用户可以重命名图像,我有一个带有图像的文件 $images=File::files('img'); $image=$images[0]; 但我不知道如何重命名图像。
谢谢

您可以先从输入中检索它。并使用您定义的文件名移动它。 您的图像将使用您指定的文件名显示

 $picture= $request->file('image');
 $fileName = 'what the image you want to call';
 $picture->move('image/foo', $fileName);

兄弟,这是我的工作。我希望,这能达到你的目的

$destinationPath = "uploadedImages";
$newName = md5_file($request->file('file_name')->getRealPath());
$guessFileExtension = $request->file('file_name')->guessExtension();
$file = $request->file('file_name')->move($destinationPath, $newName.'.'.$guessFileExtension);

你能告诉我打印($image)的结果吗?