[RESOLVED] Delete previously uploaded file from server?
Ok, so I have a page where an authorized user can upload a file... there is also a list of uploaded files (each has info in the database) and a "delete" check-box to remove it... It removes the info from the database, but how do I remove the file itself from the "docs" folder on the server?
I tried that, but it's not working. There's a "close file" thingy that gets put in before that tries to open the file and returns the error "can't open file" -- probably because the file is a PDF... should the file-type be causing a problem with the unlink() function?
Here's what I've got to delete the file:
$delFile = "docs/".$rowfile; $fh = fopen($delFile, 'w') or die("can't open file"); fclose($fh); unlink($delFile);
...and it just returns the "can't open file" error.
Except that "$rowfile" is created just a few lines up from the filename from the database. It should work, but it doesn't. I'm going to try tweaking a couple of other things & then I'll get back to you guys. Thanks a ton for the help thus far.