Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

noblemfd's avatar

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

In Laravel-8, I have created php artisan storage:link

and I have this code:

public function importCountry(Request $request)
{
    $user = Auth::user()->id;
    $userEmail = Auth::user()->email;

    $request->validate([
        'document' => 'file|mimes:xlsx|max:10000',
    ]);

    if ($request->hasFile('document'))
    {
        $type = $request['document']->getClientmimeType();
        $file_name = $request['document']->getClientoriginalName();
        $image = 'null';
        if($type === 'application/vnd.ms-excel'){
            $image = 'supported';
        }
        if($type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'){
            $image = 'supported';
        }

        if($image === 'null'){
            return $this->error('File type is Unsupported, Upload Either .XSLX file format', 401);
        }

        $rand = rand(10,10000);

        $name = $userEmail.'_'.$user.'_'.$rand.'_'.$file_name;

        $directory =  public_path('storage/file_imports/location_imports');

        $file = $request->file('document')->storeAs($directory, $name);

        $import = new CountryImport;
        $import->import($file, $directory);
    }
}

As I tried to import, I got this error:

local.ERROR: League\Flysystem\Exception: Impossible to create the root directory "C:\xampp\htdocs\idriver\server\storage\app\C:/xampp/htdocs/myapp/public/storage/file_imports/location_imports". in C:\xampp\htdocs\imyapp\vendor\league\flysystem\src\Adapter\Local.php:112

Why am I having this after I have done:

php artisan storage:link

How do I resolve it?

Thanks

0 likes
10 replies
Theraloss's avatar

Have you tried to manually create the file_imports and location_imports folders?

MichalOravec's avatar
Level 75
$directory =  'file_imports/location_imports';

$file = $request->file('document')->storeAs($directory, $name);

$import = new CountryImport;

$import->import($file, $directory); // probably here use path with storage 
noblemfd's avatar

@michaloravec , the error chaged to:

local.ERROR: InvalidArgumentException: Disk [file_imports/location_imports] does not have a configured driver

MichalOravec's avatar
$request->file('document')->storeAs($directory, $name, 'public');
noblemfd's avatar

@michaloravec - The error chaged to:

Impossible to create the root directory "C:\xampp\htdocs\myapp\storage\app/public\C:/xampp/htdocs/myapp/public/storage/file_imports/location_imports". at C:\xampp\htdocs\myapp\vendor\league\flysystem\src\Adapter\Local.php:112)

noblemfd's avatar

This is the actual code:

public function importCountry(Request $request)
{
    $user = Auth::user()->id;
    $userEmail = Auth::user()->email;

    $request->validate([
       'document' => 'file|mimes:xlsx|max:10000',
    ]);

    if ($request->hasFile('document'))
    {
        $type = $request['document']->getClientmimeType();
        $file_name = $request['document']->getClientoriginalName();
        $image = 'null';
        if($type === 'application/vnd.ms-excel'){
            $image = 'supported';
        }
        if($type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'){
            $image = 'supported';
        }

        if($image === 'null'){
            return $this->error('File type is Unsupported, Upload Either .XSLX file format', 401);
        }

        $rand = rand(10,10000);

        $name = $userEmail.'_'.$user.'_'.$rand.'_'.$file_name;

        $directory =  public_path('storage/file_imports/location_imports');

        $file = $request->file('document')->storeAs($directory, $name, 'public');

        $import = new CountryImport;
        $import->import($file, $directory);
    }
}
noblemfd's avatar

Yes @michaloravec . This:

public function importCountry(Request $request)
{
    $user = Auth::user()->id;
    $userEmail = Auth::user()->email;

    $request->validate([
       'document' => 'file|mimes:xlsx|max:10000',
    ]);

    if ($request->hasFile('document'))
    {
        $type = $request['document']->getClientmimeType();
        $file_name = $request['document']->getClientoriginalName();
        $image = 'null';
        if($type === 'application/vnd.ms-excel'){
            $image = 'supported';
        }
        if($type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'){
            $image = 'supported';
        }

        if($image === 'null'){
            return $this->error('File type is Unsupported, Upload Either .XSLX file format', 401);
        }

        $rand = rand(10,10000);

        $name = $userEmail.'_'.$user.'_'.$rand.'_'.$file_name;

        $directory =  'file_imports/location_imports';

        $file = $request->file('document')->storeAs($directory, $name, 'public');

        $import = new CountryImport;
        $import->import($file, $directory);
    }
}

gives:

local.ERROR: InvalidArgumentException: Disk [file_imports/location_imports] does not have a configured driver

noblemfd's avatar

Thanks so much. It was heading row creating the issues

Please or to participate in this conversation.