Forums
This topic is locked
unlink() help
Posted 01 Dec 2006 13:13:25
1
has voted
01 Dec 2006 13:13:25 Iain Stewart posted:
I've created a simple mp3 hosting server for education sites I cover.I've got the user logging on uploading there saved mp3 file and then confirming the database entry containing the file info and other info they can use to link to the schools blogs. All works fine until they need to remove a file. The database entries go however the mp3 file doesn't. The code I use is below
$RmFile = $_POST['FileName']; //set remove file path and fille name as variable
echo $RmFile; //print of the path of the file and file name
fopen($RmFile, 'w') or die(" can't open file " //open the file
fclose($RmFile); // close the file
unlink($RmFile) or exit (" file not deleted" ); // delete the file
the echo produces the following info
files/woodhill/winternight.mp3 which is the correct path to the file, but the file isn't removed. If I add is_writable() it returns true and also is_readable() returns true.
the fopen and close destroys the file data and its size returns to 0kb
The php is installed on windows 2003 with iis6, everything else works great apart from deleteing the file.
unlink() always returns false.
any help would be great.
Iain
head hurts, 'mental note to self, stop banging head !'
Replies
Replied 01 Dec 2006 14:59:02
01 Dec 2006 14:59:02 Iain Stewart replied:
cracked it
turns out I was actually sending files\woodhill\winternight.mp3 when I changed it to files/woodhill/winternight.mp3 all now works.
Now for a nice easy friday afternoon
Iain
head hurts, 'mental note to self, stop banging head !'
turns out I was actually sending files\woodhill\winternight.mp3 when I changed it to files/woodhill/winternight.mp3 all now works.
Now for a nice easy friday afternoon
Iain
head hurts, 'mental note to self, stop banging head !'