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...
Who is Participating?
bozoka45Connect With a Mentor Commented:
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:

$filepath = '/home/httpd/vhosts/'; //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)) {
} else {
  echo "file does not exist!";
..You wish to remove a file from a server automatically?? Is there a particular language? Does the server have FTP access?
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/';
$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)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.