I would like to create a directory but I got this error :
ErrorException in Filesystem.php line 390: mkdir(): No such file or directoryErrorException in Filesystem.php line 390: mkdir(): No such file or directory
in Filesystem.php line 390
at HandleExceptions->handleError('2', 'mkdir(): No such file or directory', 'C:\xampp\htdocs\yatan\yatan\vendor\laravel\framework\src\Illuminate\Filesystem\Filesystem.php', '390', array('path' => 'C:\xampp\htdocs\yatan\yatan\public/assets/images/projects/1/1476592434/', 'mode' => '511', 'recursive' => false, 'force' => false))
my code :
$to_main_image = time();
$path = 'assets/images/projects/'.$user_id.'/'.$to_main_image.'/';
File::makeDirectory(public_path().'/'.$path,0777);
Change the line
File::makeDirectory(public_path().'/'.$path,0777);
to
File::makeDirectory(public_path().'/'.$path,0777,true);
So that the sub-directories are also created.
if using laravel 5.8 then try this out
go to vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php and find prepareCache function and edit line no 247 -
if (!mkdir($cacheDir))
to
if (!mkdir($cacheDir,0777,true))
Adding the code snippet as well.
private function prepareCache($nsKey)
{
$cacheDir = $this->path.'/'.$nsKey;
if (!is_dir($cacheDir)) {
if (!mkdir($cacheDir,0777,true)) {
throw new Swift_IoException('Failed to create cache directory '.$cacheDir);
}
$this->keys[$nsKey] = [];
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With