• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

deleting an uploaded file

no problem deleting it from the database but how do I go about removing from the folder on ther server(linux) please help...
0
jtrudeau
Asked:
jtrudeau
1 Solution
 
InteractiveMindCommented:
..You wish to remove a file from a server automatically?? Is there a particular language? Does the server have FTP access?
0
 
jtrudeauAuthor Commented:
all programming was done in php using mysql, this is what I used to upload the file, how do I delete it no lol


<?
$uploaddir = '/home/httpd/vhosts/creationexpress.com/subdomains/admin/httpdocs/cards/';
$uploadfile = $uploaddir . $_FILES['cardFR']['name'];
if (move_uploaded_file($_FILES['cardFR']['tmp_name'], $uploadfile)) {
chmod ($uploadfile, 0755);
      print("<b>Upload Status:</b> Successful !");
} else {
      print("<b>Upload Status:</b> Unsuccessful !");
      }
      ?>

as for ftp acces the server is mine I have full control, please just let me know what I have to do to delete the file once the "delete button" is pressed for a particular record (in my case a product image)
0
 
bozoka45Commented:
Well, I'm assuming that you're somehow tracking the files with the database and you know the filename of the file you want to delete.

This code will work:

<?PHP
$filepath = '/home/httpd/vhosts/creationexpress.com/subdomains/admin/httpdocs/cards/'; //Path from above
$filename = $filepath . ''; //filename of the file you want to delete, not sure where you'll get that from.
if(file_exists($filename)) {
  unlink($filename);
} else {
  echo "file does not exist!";
}
?>
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now