Unlinking an image from a website

I have an update form and one of the options to be update are the images
<input name="image1" type="file" class="style81" id="image1" size="20" /> thats a sample of the  file field.
Lets say a user added an image when they were adding a product and now with the update of that product they want to unlink a specific image - remove it from the website
how can it be done?
below is my update statement, generated with dreamweaver
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE enginesubcategory SET make=%s, model=%s, `year`=%s, engine=%s, cc=%s, cyl=%s, type=%s, fuel=%s, thumbnail=IFNULL(%s,thumbnail), product=%s, comments=%s, commentsExtras=%s, image1=IFNULL(%s,image1), image2=IFNULL(%s,image2), image3=IFNULL(%s,image3), image4=IFNULL(%s,image4), image5=IFNULL(%s,image5), image6=IFNULL(%s,image6), image7=IFNULL(%s,image7), image8=IFNULL(%s,image8), image9=IFNULL(%s,image9), image10=IFNULL(%s,image10), image1Big=IFNULL(%s,image1Big), image2Big=IFNULL(%s,image2Big), image3Big=IFNULL(%s,image3Big), image4Big=IFNULL(%s,image4Big), image5Big=IFNULL(%s,image5Big), image6Big=IFNULL(%s,image6Big), image7Big=IFNULL(%s,image7Big), image8Big=IFNULL(%s,image8Big), image9Big=IFNULL(%s,image9Big), image10Big=IFNULL(%s,image10Big) WHERE id=%s",
                       GetSQLValueString($_POST['make'], "text"),
                       GetSQLValueString($_POST['model'], "text"),
                       GetSQLValueString($_POST['year'], "text"),
                       GetSQLValueString($_POST['engine'], "text"),
                       GetSQLValueString($_POST['cc'], "text"),
                       GetSQLValueString($_POST['cyl'], "text"),
                       GetSQLValueString($_POST['type'], "text"),
                       GetSQLValueString($_POST['fuel'], "text"),
                       GetSQLValueString($_POST['thumbnail'], "text"),
                       GetSQLValueString($_POST['product'], "text"),
                       GetSQLValueString($_POST['details'], "text"),
                       GetSQLValueString($_POST['extraDetails'], "text"),
                       GetSQLValueString($_POST['image1'], "text"),
                       GetSQLValueString($_POST['image2'], "text"),
                       GetSQLValueString($_POST['image3'], "text"),
                       GetSQLValueString($_POST['image4'], "text"),
                       GetSQLValueString($_POST['image5'], "text"),
                       GetSQLValueString($_POST['image6'], "text"),
                       GetSQLValueString($_POST['image7'], "text"),
                       GetSQLValueString($_POST['image8'], "text"),
                       GetSQLValueString($_POST['image9'], "text"),
                       GetSQLValueString($_POST['image10'], "text"),
                       GetSQLValueString($_POST['image1Big'], "text"),
                       GetSQLValueString($_POST['image2Big'], "text"),
                       GetSQLValueString($_POST['image3Big'], "text"),
                       GetSQLValueString($_POST['image4Big'], "text"),
                       GetSQLValueString($_POST['image5Big'], "text"),
                       GetSQLValueString($_POST['image6Big'], "text"),
                       GetSQLValueString($_POST['image7Big'], "text"),
                       GetSQLValueString($_POST['image8Big'], "text"),
                       GetSQLValueString($_POST['image9Big'], "text"),
                       GetSQLValueString($_POST['image10Big'], "text"),
                       GetSQLValueString($_POST['engineSubCatID'], "int"));

  mysql_select_db($database_adsCyprus, $adsCyprus);
  $Result1 = mysql_query($updateSQL, $adsCyprus) or die(mysql_error());

  $updateGoTo = "updateRecordProductsConfirmation.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}

Open in new window

dino_angelidesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MichaelT_Commented:
OK is the image stored on disk? If so then you simply have to get the path and the filename and use the "unlink" command

ie
$path="path/image/is/stored";
// image name would probably need to be retrieved from the database
$image="test.png"
chmod("$path/$image"], 0755); // make sure you have permissions to remove it
unlink("$path/$image"); // removes it

If you need more clarification let me know.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rustamonlineCommented:
As i understood, you have 10 images within an one record. When you want to delete image from the server, delete it from Form variables, for example, let's say you want to delete image1:
<input name="image1" type="file" class="style81" id="image1" size="20" />
Free this from value in the HTML form by mean javascript:

document.getElementById("image1").value = "";

When you submit form, $_FILES['image1'] variable on the server side will be empty. According to this you can identify which image file is going to be deleted.

Deleting is showed in the comment of MichaelT_
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

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.