1
votes

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'
);
1

1 Answers

1
votes

How about this? It should even be OS-agnostic:

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