Monday, September 26, 2011

File Handling in Drupal - file_delete()

<?php
 
 
//You should use single quotes here because the path has backslashes!
 
$path = 'c:\windows\temp/test.txt';
 
 
//Try to delete the file
 
$success = file_delete($path);
 
 
//If the file was successfully deleted, update the database
 
if ($success){

   
db_query('DELETE FROM {files} WHERE filepath = "%s"', $path);
  } else {
    echo "There is some problem in Deleting the file!";
  }
 
?>

No comments:

Post a Comment

Followers