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, ∼2126🔥, 0💬
Popular Posts:
Where to get the detailed description of the json_encode() Function in PHP? Here is the detailed des...
How to send an FTP request with the urllib.request.urlopen() function? If an FTP server supports ano...
What Azure AD App Registration Manifest? Azure AD App Registration Manifest is JSON file that contai...
How to add request query string Parameters to my Azure API operation to make it more user friendly? ...
How To Avoid the Undefined Index Error in PHP? If you don't want your PHP page to give out errors as...