function _upload_element_delete in Upload element 6
Private helper function for to delete files during the save process
Parameters
$fid The fid of a file object to delete.:
1 call to _upload_element_delete()
- upload_element_save in ./
upload_element.module - Saves an uploaded file
File
- ./
upload_element.module, line 687 - A module that provides two new elements to the FAPI for file handling.
Code
function _upload_element_delete($fid) {
$result = db_query('SELECT * FROM {files} WHERE fid = %d', $fid);
if ($file = db_fetch_object($result)) {
if (file_exists($file->filepath)) {
// If files that exist cannot be deleted, log it for manual deletion.
if (!file_delete($file->filepath)) {
watchdog('upload_element', 'Could not delete file "%path".', array(
'%path' => $file->filepath,
), 'error');
}
}
else {
watchdog('upload_element', 'Attempting to delete missing file "%path".', array(
'%path' => $file->filepath,
), 'error');
}
}
db_query('DELETE FROM {files} WHERE fid = %d', $fid);
}