deleting an uploaded file

Posted on 2005-05-13
Last Modified: 2010-04-17
no problem deleting it from the database but how do I go about removing from the folder on ther server(linux) please help...
Question by:jtrudeau
    LVL 25

    Expert Comment

    ..You wish to remove a file from a server automatically?? Is there a particular language? Does the server have FTP access?

    Author Comment

    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)
    LVL 1

    Accepted Solution

    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!";

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    sum13 challenge 24 69
    post4 challenge 28 70
    Replace a tag with sed 2 32
    mapBully challenge 6 53
    Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
    Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now