[thelist] How do I delete uploaded files in PHP?
Nan Harbison
nan at nanharbison.com
Mon Nov 12 14:55:03 CST 2007
Hi all,
I am working on a website where clients can upload a resume, and can upload
a new resume in its place. This is working just fine. However, I am having
the file names be randomly generated, so the old file is not overwritten. I
need to be able to delete the old file, but I am having trouble a tutorial
on how to do this, all the links I get in google are for little applications
to manage file uploads and downloads.
-I tried using 'unlink' but it didn't work
-I tried this but it isn't working. I didn't get any error messages, it just
doesn't delete the old resume.
$file = 'resumes/'.$_POST['oldresume'];
$ftp_server = 'my ftp address';
$ftpuser = 'myusername;
$ftppass = my password;
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftpuser, $ftppass);
// try to delete $file
if (ftp_delete($conn_id, $file)) { // the ftp function
echo '$file deleted successful';
} else {
echo 'could not delete $file';
}
// close the connection
ftp_close($conn_id);
Can someone please explain to me how I should do this, or point me to a
resource that show me?
Thanks!
Nan
More information about the thelist
mailing list