Romentigo
4 months ago
421
3
Laravel

How to delete images from public folder?

Posted 4 months ago by Romentigo

I'm using Laravel + Vue.js with Laravel Mix. One day I added to public folder some images. I've just wanted to replace them with new ones, but there are still old images instead of new. If I add images by other names, they appear, but I can't replace old ones. I've tried code like this below:

public function removeImage()
    {
        if(file_exists(public_path('./images/students.png'))){
            unlink(public_path('./images/students.png'));
        }else{
            dd('File does not exists.');
        }
    }

I have the next path: public/images/some images. I've run this function with different images and seems like succesfully, but they are still on my server. How can I remove them?

Please sign in or create an account to participate in this conversation.