DEV Community

Julian
Julian

Posted on

How to delete a file uploaded in database

To delete a file loaded on a server, we must enter the following code in our program:

// We proceed to delete
if (! unlink ('uploads /'.$ file)) {
// print error when deleting
echo 'Error deleting';
} else {
// File deleted
echo 'File deleted';
}

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay