|
I have the attached script which works fine to delete a named file (in tis case 12.jpg) but i want that file name to be deleted to be specified in a form field in a browser. In other words the user enters the file name to be removed and submits the form and the script deletes that file. Any help would be apprciated.
<?php
// set up the settings
$file = 'public_html/admin/12.jpg';
$ftp_server = 'ftp.here.com';
$ftpuser = 'user';
$ftppass = 'abcd1234';
// 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\n";
} else {
echo "could not delete $file\n";
}
// close the connection
ftp_close($conn_id);
?>
|