Page 1 of 1
file delete code not working - i'm using PhpNuke
Posted: Fri Sep 08, 2006 2:54 am
by wqr786
im working on PhpNuke
i made a folder uploads/audio/
and within that folder i uploaded some files of .mp3 etc
now i need to delete those files using the php code
im trying to delete them with the following code but its not working:
unlink("uploads/audio/somefile.mp3");
but file is not being deleted. urgent help needed, please.
-Waqar
Posted: Fri Sep 08, 2006 1:06 pm
by feyd
I think you're going to need to get a bit more specific. Your code and errors from your error logs could be of use here for instance.
Posted: Sat Sep 09, 2006 2:46 am
by wqr786
well, the i made a .txt file, in the root the unlink() is working, but when i try to unlink() the file in a folder, it doesn't work, ill provide more information after a little debugging...
works
unlink("somefile.txt");
does not work:
unlink("folder1/folder2/somefile.txt");
Posted: Sat Sep 09, 2006 3:09 am
by wtf
check folder/file permissions
here's my code, please help, file not being deleted...
Posted: Sat Sep 09, 2006 8:22 am
by wqr786
patrikG | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
here's my code, help required, i can't figure out why the file is not being deleted.
besides this, im using EasyPHP on Windows XP, so if anyone knows how to check the files/folders permissions in it please let me know. however, please remember, the file.txt is deleted if its not in a folder, but if it is in a folder, im unable to to delete it.
Code: Select all
case "deleteaudio":
if($_REQUEST['id']!=NULL)
{
//QUERY TO SELECT AND DELETE THE FILE FROM THE SERVER (LOCATION)
$sql = "SELECT location FROM ".$prefix."_audio WHERE id=".$_REQUEST['id'];
$result = $db->sql_query($sql);
// row[location] variable is actualy the path and filename which is stored in database, so you can assume it
// to be folder1/folder2/file.txt
echo $row[location];
//DELETING (UNLINKING) THE FILE
if(unlink($row[location]))
{
echo "<p>File deleted from server, please wait ...</p>";
}
else
{
echo "<p>File NOT deleted from server location ...</p>";
}
//QUERY TO DELETE THE DETAILS OF THE AUDIO FILE FROM DATABASE
$sql="DELETE FROM ".$prefix."_audio WHERE id=".$_REQUEST['id'];
$db->sql_query($sql);
echo "<p>Audio successfully deleted from database ...</p>";
}
break;
patrikG | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Sat Sep 09, 2006 9:53 am
by Mordred
what do file_exists() and is_writable() say?