Ad

Laravel Storage Returns: Mkdir(): File Exists

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

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?

Ad

Answer

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:

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

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

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.

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?

Ad
source: stackoverflow.com
Ad