Tools, FAQ, Tutorials:
Removing a File in PHP
How To Remove a File in PHP?
✍: FYIcenter.com
If you want to remove an existing file, you can use the unlink() function. Here is a PHP script example on how to use unlink():
<?php
if (file_exists("/temp/todo.txt")) {
unlink("/temp/todo.txt");
print("File removed.\n");
} else {
print("File does not exist.\n");
}
?>
This script will print:
File removed.
If you run this script again, it will print:
File does not exist.
⇐ Removing an Empty Directory in PHP
2016-11-20, ∼2887🔥, 0💬
Popular Posts:
How to Build my "sleep" Docker image from the Alpine image? I want the container to sleep for 10 hou...
How to create a VC# class and build it into a library? If you want to create a VC# class and build i...
How To Remove Slashes on Submitted Input Values in PHP? By default, when input values are submitted ...
Why am I getting this "Docker failed to initialize" error? After installing the latest version of Do...
How To Merge Cells in a Column? If you want to merge multiple cells vertically in a row, you need to...