Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP Delete File
<?php
/**
* Deleting file
* @param string $fullpath Filename with its full path
* @return array key => result
*/
function deleteFile( $fullpath ) {
if (file_exists($fullpath)) {
$hasBeenDeleted = unlink($fullpath);
if ($hasBeenDeleted) {
$result = array(
"result" => 1,
"message" => "File has successfully been deleted !"
);
}
} else {
$result = array(
"result" => 0,
"message" => "File was not found !"
);
}
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment