Laravel League\Flysystem\Exception: Impossible to create the root directory

Viewed 13961

I have this code which works perfectly on my local pc (MAC), but when I push everything into production this error appears:

local.ERROR: League\Flysystem\Exception: Impossible to create the root directory

foreach (explode('#', $pics_urls) as $url)
            {
                $curlCh = curl_init();
                curl_setopt($curlCh, CURLOPT_URL, $url);
                curl_setopt($curlCh, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($curlCh, CURLOPT_SSLVERSION, 3);
                $curlData = curl_exec($curlCh);
                curl_close($curlCh);
                if(!empty($curlData)) {
                    Storage::disk('local')->put('public/photos/' . $bid->lot_id . '/' . ++$num . '.jpg', $curlData);
                }
            }

How can I fix this problem?

2 Answers

I just had this error. It was actually the same error but one of the project dependencies was trying to create a folder called /something and it was failing because my user didn't have permission to create folders in the root of the hard disk.

The solution for me was to do sudo mkdir /something, and then composer install worked.

It's definitely permission related if anyone else stumbles into this.

I had this same problem.

Just give permission to you storage.

sudo chmod -R 777 storage/

Note: This command will give full permission to your folder.

Related