laraveleloquentlaravel-8laravel-controllerlaravel-10

Laravel trying to store image file in 3 different folder


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

Solution

  • \File::copy($path1, $path2); 
    \File::copy($path1, $path3);