2

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?

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
derdida
  • 14,784
  • 16
  • 90
  • 139
  • Are you sure directory `storage_path().'/app/images'` exists? Does it has correct file permissions? – Marcin Nabiałek Dec 29 '15 at 15:14
  • Yes it exists, and it worked already with a previous version (ill guess L5.0) - its strange - because i am unable to check ANY files with Storage::get(); - always getting the same error – derdida Dec 29 '15 at 15:16
  • What exact version do you use? Have you tried upgrading to last 5.1 version? – Marcin Nabiałek Dec 29 '15 at 15:49
  • I am using the Version 5.1.27 (LTS) - already updated Laravel, but still bringing the same error – derdida Dec 30 '15 at 08:52

1 Answers1

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:

'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?

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
  • Thanks - ill done a fresh install and it worked. So deleted all the permissions for the User and tried again. And it works. So (i am not sure) but maybe it was really a file permission problem. The error is a little bit weird, because i know that there is a "Permission denied" error too. Thanks for pointing me into that direction! – derdida Dec 30 '15 at 13:09
  • i create folder by using generate current date, how can i applicated in filesystem.php – Freddy Sidauruk Jul 31 '17 at 08:57