Forums
This topic is locked
unlink() help
Posted 18 years ago
1
has voted
18 years ago 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 "

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 18 years ago
18 years ago 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 !'