below is my code.. bt cant delete the file, help please...y cant it delete?
function deleteFile($id_file) {
$infoFile = $this->getFileInfo($id_file);
$folderPath = $this->folderPath($infoFile["id_folder"]);

if (substr($infoFile["file_name"], 0, 3) == ".ht") {
$this->error = 6;
return false;
}

if (!file_exists($this->root . "files" . $folderPath . SEP . $infoFile["file_name"])) {
$q = "UPDATE " . TABLE_PREFIX . "files SET file_flag = 1 WHERE id_file = '" . $id_file . "'";
query($q);
$this->error = 6;
return false;
}

if (@unlink($this->root . "files" . $folderPath . SEP . $infoFile["file_name"])) {
$q = "DELETE FROM " . TABLE_PREFIX . "files WHERE id_file = '" . $id_file . "'";
query($q);

$q = "OPTIMIZE TABLE " . TABLE_PREFIX . "files";
query($q);

$this->updateFolderSize($infoFile["id_folder"], $infoFile["file_size"], "-");
$this->updateFolderTime($infoFile["id_folder"]);
return true;
}
return false;
}

Recommended Answers

All 3 Replies

Member Avatar for diafol

use code tags - it's v difficult to follow.

1) Is

$this->root . "files" . $folderPath . SEP . $infoFile["file_name"]

pointing to the file correctly (no problems with path / filename)?

2) Replace @unlink with unlink -> @ symbol suppresses errors, you might wanna see all the errors while debugging

using @ and not using makes no defference... still not deleteing, pliz help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.