英文:
Laravel trying to store image file in 3 different folder
问题
我尝试将图像存储在公共文件夹内的3个不同文件夹中,现在我能够存储在两个不同的文件夹中,但当我添加第三个文件夹路径时,它无法复制到第三个文件夹,请帮我解决这个问题。
我的两个文件夹复制工作代码
$input['student_photo'] = time() . '.' . $request->student_photo->getClientOriginalExtension();
$folder1 = public_path('public/path1/');
$path1 = $folder1 . $input['student_photo']; // 路径1
$request->student_photo->move($folder1, $input['student_photo']); // 图像保存在第一个文件夹
$path2 = public_path('public/path2/') . $input['student_photo']; // 路径2
\File::copy($path1, $path2);
我尝试复制第三个文件夹的代码,但不起作用
$input['student_photo'] = time() . '.' . $request->student_photo->getClientOriginalExtension();
$folder1 = public_path('public/path1/');
$path1 = $folder1 . $input['student_photo']; // 路径1
$request->student_photo->move($folder1, $input['student_photo']); // 图像保存在第一个文件夹
$path2 = public_path('public/path2/') . $input['student_photo']; // 路径2
$path3 = public_path('public/path3/') . $input['student_photo']; // 路径3
\File::copy($path1, $path2, $path3);
希望这可以帮助您解决问题。
英文:
I'm trying to store image in 3 different folder inside public folder now I'm able to store in two different folder but when I added 3rd folder path but it was not coping in 3rd folder help me to solve this.
my two folder copying Working code
$input['student_photo'] = time().'.'.$request->student_photo->getClientOriginalExtension();
$folder1 = public_path('public/path1/');
$path1 = $folder1 . $input['student_photo']; // path 1
$request->student_photo->move($folder1, $input['student_photo']); // image saved in first folder
$path2 = public_path('public/path2/') . $input['student_photo']; // path 2
\File::copy($path1, $path2);
I tired this code for copy 3rd folder but not working
$input['student_photo'] = time().'.'.$request->student_photo->getClientOriginalExtension();
$folder1 = public_path('public/path1/');
$path1 = $folder1 . $input['student_photo']; // path 1
$request->student_photo->move($folder1, $input['student_photo']); // image saved in first folder
$path2 = public_path('public/path2/') . $input['student_photo']; // path 2
$path3 = public_path('public/path3/') . $input['student_photo']; // path 3
\File::copy($path1, $path2, $path3);
答案1
得分: 0
\File::copy($path1, $path2);
\File::copy($path1, $path3);
英文:
\File::copy($path1, $path2);
\File::copy($path1, $path3);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论