File `{$path}` does not exist error In laravel

3.8k Views Asked by At

Can you please help me this error,i am stuck in that error from two days. i have work in laravel multiple images upload.but whenever i upload the images it will show below error msg..

Spatie\MediaLibrary\Exceptions\FileCannotBeAdded\FileDoesNotExist File D:\xampp\htdocs\abc\storage\prop_images/5f211fbd7fa1a_p1.jpg does not exist

namespace Spatie\MediaLibrary\Exceptions\FileCannotBeAdded;

use Spatie\MediaLibrary\Exceptions\FileCannotBeAdded;

class FileDoesNotExist extends FileCannotBeAdded
{
    public static function create(string $path)
    {
        --->>>> return new static("File `{$path}` does not exist");  <<<<<----
    }
}

i have use some solutions like clear cache,config, php artisan storage:link....also changes storage path.Given bellow is my image uploading code in controller.i have use dropzone media library to upload images.

foreach ($request->input('prop_images', []) as $file) {
            $addProperty->addMedia(storage_path('prop_images/' . $file))->toMediaCollection('prop_images');
}

thank you in advance... :)

1

There are 1 best solutions below

0
On

I was having the same issue and in the end, it was an error in my logic, that was calling twice the temporary file so, correctly, it was giving error on the second time, as the temporary file had already been removed.

Basically, check your code for "addMediaFromRequest()" calls and review if it's more than one call trying to use THE SAME UPLOADED FILE, as it's going to break.

You can see more details at https://github.com/spatie/laravel-medialibrary/issues/1062