Laravel Storage返回:mkdir():文件存在

时间:2022-10-18 20:40:30

When I'll try to check if a file exists in Laravel 5.1 I am always getting this error:

当我试图检查Laravel 5.1中是否存在文件时,我总是收到此错误:

ErrorException in Local.php line 95: 
mkdir(): File exists

I don't know what could here be wrong, I want to check if a file exists or not with:

我不知道这可能出现什么问题,我想检查一个文件是否存在:

$exists = Storage::disk('images')->has('filename.jpg');

dd($exists);

Disk "images":

磁盘“图像”:

'disks' => [

    'local' => [
        'driver' => 'local',
        'root'   => storage_path().'/app',
    ],

    'images' => [
        'driver' => 'local',
        'root'   => storage_path().'/app/images',
    ],

Any ideas?

有任何想法吗?

1 个解决方案

#1


1  

If I were you, I would try fresh installation to verify if you experience the same problem on fresh installation:

如果我是你,我会尝试全新安装来验证你是否在全新安装时遇到同样的问题:

composer create-project laravel/laravel testfiles 5.1.*

add into filesystems.php in disks:

在磁盘中添加到filesystems.php:

'images' => [
        'driver' => 'local',
        'root'   => storage_path().'/app/images',
    ],

Modify in Http/routes.php file so root path looks like this:

在Http / routes.php文件中修改,以便根路径如下所示:

Route::get('/', function () {
    $exists = Storage::disk('images')->has('filename.jpg');
    dd($exists);
    return view('welcome');
});

Of course you need to also set up domain for this sample project.

当然,您还需要为此示例项目设置域。

On mine PC I'm getting false without any error.

在我的PC上我没有任何错误就变得虚假。

If you have this error on fresh install, well, it's a problem, if not, maybe you could also publish your composer.json and composer.lock files to verify it on exact libarries you are using?

如果你在全新安装时遇到这个错误,那么,这是一个问题,如果没有,也许你也可以发布你的composer.json和composer.lock文件来验证你正在使用的确切的libarries?

#1


1  

If I were you, I would try fresh installation to verify if you experience the same problem on fresh installation:

如果我是你,我会尝试全新安装来验证你是否在全新安装时遇到同样的问题:

composer create-project laravel/laravel testfiles 5.1.*

add into filesystems.php in disks:

在磁盘中添加到filesystems.php:

'images' => [
        'driver' => 'local',
        'root'   => storage_path().'/app/images',
    ],

Modify in Http/routes.php file so root path looks like this:

在Http / routes.php文件中修改,以便根路径如下所示:

Route::get('/', function () {
    $exists = Storage::disk('images')->has('filename.jpg');
    dd($exists);
    return view('welcome');
});

Of course you need to also set up domain for this sample project.

当然,您还需要为此示例项目设置域。

On mine PC I'm getting false without any error.

在我的PC上我没有任何错误就变得虚假。

If you have this error on fresh install, well, it's a problem, if not, maybe you could also publish your composer.json and composer.lock files to verify it on exact libarries you are using?

如果你在全新安装时遇到这个错误,那么,这是一个问题,如果没有,也许你也可以发布你的composer.json和composer.lock文件来验证你正在使用的确切的libarries?