PDA

View Full Version : deleting user uploaded files... its a tuffy


genuineskate
11-04-2006, 05:24 PM
ok what command can i use to delete a file that is not in the same directory, unlike unlink?


tia,
-ajp

erisco
11-04-2006, 06:11 PM
Uhm, unlink doesn't have to be called in the same directory to delete a file. You can very well use whatever path is valid. Just like you would with include(), or mkdir(), or opendir(), you get my point.

scoutt
11-10-2006, 01:55 AM
unlink() is your only choice.

genuineskate
11-22-2006, 08:11 PM
but when i use unlink like so:

function dsong($num, $user)
{
$myfile = 'upload/songs/'. $user . $num . '.mp3';
echo $myfile;
unlink($myFile);
}

i get:

Warning: unlink(): No such file or directory in /home/ajpsno/public_html/admin/admindex.php on line 187


the place the file is located is wellcanyousing.com/upload/songs/

erisco
11-22-2006, 08:35 PM
So try this then
function dsong($num, $user)
{
$myfile = '/home/ajpsno/public_html/upload/songs/'. $user . $num . '.mp3';
echo $myfile;
unlink($myFile);
}
Remember without the starting slash you are not working from root.

genuineskate
12-04-2006, 08:48 PM
nope now i have t in the same directiory and it still doesnt work

function dsong($num, $user)
{
$myfile = $user . $num . '.mp3';
chmod("$myfile", 0777);
echo $myfile;
unlink($myFile);
}

same error "file not found"

hm............?
-ajp

scoutt
12-04-2006, 08:53 PM
you have to use the full path, no matter what.

why are you chmoding it when you are just deleting it? you shouldn't have to do that. and do you realize that you are in the admin so the mp3 file has to be there as well?

Vege
12-05-2006, 02:13 AM
unlink() is your only choice.
http://php.net/ftp ?
Well, unlink is indeed the preferred method i suppose.

¥åßßå
12-05-2006, 02:56 AM
$myfile = '/home/ajpsno/public_html/upload/songs/'. $user . $num . '.mp3';
echo $myfile;
unlink($myFile);

$myfile != $myFile;

¥

scoutt
12-05-2006, 09:20 AM
good catch ¥åßßå :)