我想创建一个目录,但是我收到了这个错误:
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))
我的代码:
$to_main_image = time();
$path = 'assets/images/projects/'.$user_id.'/'.$to_main_image.'/';
File::makeDirectory(public_path().'/'.$path,0777);
答案 0 :(得分:11)
更改行
File::makeDirectory(public_path().'/'.$path,0777);
到
File::makeDirectory(public_path().'/'.$path,0777,true);
这样也可以创建子目录。
答案 1 :(得分:0)
如果使用laravel 5.8,请尝试一下
转到供应商/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php,找到prepareCache函数并编辑第247行-
if (!mkdir($cacheDir))
到
if (!mkdir($cacheDir,0777,true))
也添加代码段。
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] = [];
}
}