-1

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);
4
  • What errors does it give? What are the permissions on all folders? Commented Feb 18, 2023 at 14:39
  • @Sergey Makarov i dont get any error but 3rd path folder dont get any image if i check Commented Feb 18, 2023 at 14:41
  • 1
    I think it should be \File::copy($path1, $path2); \File::copy($path1, $path3); Commented Feb 18, 2023 at 14:45
  • @Sergey Makarov yes working thank you Commented Feb 18, 2023 at 14:49

1 Answer 1

0
\File::copy($path1, $path2); 
\File::copy($path1, $path3);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.