hre is my code for deleting a file, wats missing?

$getFields($fields);
$infoFile = $doc->getFileInfo($file);

$title = _l("Delete a document");

if ($action == "dodelete" && $file)
{
    if ($doc->hasRight($_SESSION["Sid_user"], "d", $dir))
    {
        if (!$doc->deleteFile($file))

            $error = $doc->errstr();
        else
            $error = _l("Document successfully deleted !");
    }
    else
        $error = _l("You cannot delete documents !");

Hard to say, I assume it's not working ? If the file is not deleted, check if $file contains a full path, or a relative one. The problem could be in deleteFile(), so show what it does.

its colling this fuction... yet not deleting, ie the previous code colls the following code.

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;
}

nothing happens, no error, bt no deletion made

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.