staticcode's avatar

How to upload files outside of Laravel

I tried everything but cannot get a file upload to work.

I want it to upload to:

/var/www/mysite.com/uploads

Laravel is located at:

/var/www/mysite.com/admin/public/

Latest thing I tried was making a filesystem like this:

'uploads' => [
            'driver' => 'local',
            'root' => '/var/www/mysite.com/uploads'
        ]

I also tried

'uploads' => [
            'driver' => 'local',
            'root' => '../../uploads'
        ]

none of them did work.

Can anyone please tell me how I can upload files, outside of my Laravel directory to the directory I specified above?

EDIT: The error I receive:

League \ Flysystem \ Exception Impossible to create the root directory "/var/www/mysite.com/uploads/image.jpg".

Also tried this:

        'uploads' => [
            'driver' => 'local',
            'root' => dirname(dirname(dirname(__FILE__))).'/uploads'
        ]

with controller code:

$path = $request->file('image')->store(
                'image.jpg', 'uploads'
            );
0 likes
1 reply
MikeMacDowell's avatar

Sounds like your permissions aren't set properly for the file location

Please or to participate in this conversation.