Skip to content

Instantly share code, notes, and snippets.

@rleger
Created April 20, 2014 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rleger/11110416 to your computer and use it in GitHub Desktop.
Save rleger/11110416 to your computer and use it in GitHub Desktop.
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