Problem deleting file in laravel 5

I am trying to delete a file in a laravel 5 application. My controller code

public function deleteImages(){
        $image = public_path() . '/uploads/images/'.Input::get('image');
        Storage::Delete($image);
    }

I get an error like

local.ERROR: exception 'League\Flysystem\FileNotFoundException' with message 'File not found at path: var/www/html/wonders/uploads/images/Copy1Copy1Kuruva-Islands.jpg' in /var/www/html/wonders/vendor/league/flysystem/src/Filesystem.php:381

But the file does exist, and the path is correct. But I wonder why this shows such an error.

+4
source share
3 answers

In the documentation, I found:

When using the local driver, please note that all file operations are related to the root directory defined in your configuration file. By default, this value is set to the repository / application directory . Therefore, the following method will save the file in storage / app / file.txt:

Storage::disk('local')->put('file.txt', 'Contents');

, Storage::delete , .

, Laravel Recipies:

// Delete a single file
\File::delete($filename);

// Delete multiple files
\File::delete($file1, $file2, $file3);

// Delete an array of files
$files = array($file1, $file2);
\File::delete($files);

\, Laravel 5.

+2

, : , ? , - .

, , debian/apache2 www-, 644.

0

Source: https://habr.com/ru/post/1620690/


All Articles