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, ∼2216🔥, 0💬
Popular Posts:
How to use the RSS Online Validator at w3.org? You can follow this tutorial to learn how to use the ...
What is Azure API Management Gateway? Azure API Management Gateway is the Azure Web server that serv...
How to Build my "sleep" Docker image from the Alpine image? I want the container to sleep for 10 hou...
How To Truncate an Array in PHP? If you want to remove a chunk of values from an array, you can use ...
How To Move Uploaded Files To Permanent Directory in PHP? PHP stores uploaded files in a temporary d...