Have you tried to manually create the file_imports and location_imports folders?
Aug 10, 2021
10
Level 9
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
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
Please or to participate in this conversation.