sabin maharjan
sabin maharjan

Reputation: 107

Upload image from laravel api to core php project folder

I have made Laravel API, which works with Android. This project is integrated to php web project. Both project are hosted in same hosting, but are in different folder.

In web project, image is uploaded in web project folder, and from laravel api image is uploaded to it's project folder only. Now I want to upload image from laravel api to the other project's upload directory.

Image upload code:

                $imageName = $rand . $image . $userid . "." . $ext;

             $request->file('image_name')->move(
                 'http://corephp/webProject/upload/' . $year . "/" . $month , $imageName

            );

when tried to upload, the problem says: Unable to create the directory .

but this works for laravel directory only:

  $request->file('image_name')->move(
                base_path() . '/public/uploads/' . $year . "/" . $month, $imageName
            );

Upvotes: 0

Views: 515

Answers (1)

KmasterYC
KmasterYC

Reputation: 2354

Change
'http://corephp/webProject/upload/' . $year . "/" . $month
To
base_path("../../corephp/webProject/upload/$year/$month")

Upvotes: 1

Related Questions