Search code examples
phplaravelfile-uploadlaravel-5.3

How to upload image from one project to another project laravel


I have two laravel project i use code in my Myfirstproject to upload to Mysecondproject public\src\img\upload directory.

I try these code in Myfirstproject:

if ($request->hasFile('images')) {
         $destinationPath='Mysecondproject\public\src\img\upload';
            if ($files = $request->file('images')) {
                foreach ($files as $file) {
                    $name = $file->getClientOriginalName();
                    $file->move($destinationPath, $name);
                    $images[] = $name;
                }
           }
      }

But it's not working, any solution for these?


Solution

  • Please try absolute path in $destinationPath as C:\Mysecondproject\public\src\img\upload or D:\Mysecondproject\public\src\img\upload.