1/*
2Deleting files is a concept in file handeling of PHP
3We can remove or delete the file from real folder path using below code
4*/
5
6unlink($Your_file_path); // direct deleting the file
7
8/* Delete file if its exist in folder */
9
10if (file_exists($Your_file_path)) {
11 unlink($Your_file_path);
12}
13
14/*
15I hope it will help you.
16Namaste
17*/
1// delete file function, if silent is false, function will throw exception
2function deleteFile($fullFileName, $silent=0) {
3 if (file_exists($fullFileName)) {
4 unlink($fullFileName);
5 return TRUE;
6 } else {
7 if ($silent == 1) {
8 return FALSE;
9 } else {
10 throw new \InvalidArgumentException('File "'.$fullFileName.'" not exists.');
11 }
12 }
13}