I have a bit of situation here. What I have below is a piece of code where I have stated that if the form us submitted (if the user clicks on the "Upload" button"), then store the name of the file into the database. This code is below:Code of the Form:\[code\] var $fileImage = $("<form action='imageupload.php' method='post'enctype='multipart/form-data' target='upload_target' onsubmit='return startImageUpload(this);' class='imageuploadform' ><label>" + "Image File: <input name='fileImage' type='file' class='fileImage' /></label><br/><br/><label class='imagelbl'>" + "<input type='submit' name='submitImageBtn' class='sbtnimage' value='http://stackoverflow.com/questions/10560001/Upload'/> </label>" + "</p><p class='imagef1_cancel' align='center'><label>" + "<input type='button' name='imageCancel' class='imageCancel' value='http://stackoverflow.com/questions/10560001/Cancel'/></label>" + "</p><p class='listImage' align='left'></p>" +"<iframe class='upload_target' name='upload_target' src='http://stackoverflow.com/questions/10560001/#' style='width:0;height:0;border:0px;solid;#fff;'></iframe></form>")\[/code\]Below is the imageupload.php page where that when the form is submitted, it inserts a row into the database of the file's name:\[code\]<?php...$result = 0; move_uploaded_file($_FILES["fileImage"]["tmp_name"], "ImageFiles/" . $_FILES["fileImage"]["name"]); $result = 1; $imagesql = "INSERT INTO Image (ImageFile) VALUES ('ImageFiles/".mysql_real_escape_string($_FILES['fileImage'] ['name'])."')"; mysql_query($imagesql); } mysql_close();?>\[/code\]Above shows how a database row can be inserted of the file name when the user clicks on the "Upload" button.Now the problem I have is that I also have a "Cancel" button in the form, so that if the user wishes to cancel an upload of a file which the file is uploading, then they can do this by clicking on the "Cancel" button. But the problem is that I want it to delete the row it has just inserted (As that when the user has clicked on "Upload" to upload the file, it would of inserted the name of the file into the database). But it is not deleting the database row. So my question is that when the user clicks on the "Cancel" button, how can the code below be edited so that it deletes the database row containing the file name of the file that was uploading but then cancelled?Below is the cancel button function:\[code\]var _cancelimagecounter = cancelimagecounter;$(".imageCancel").on("click", function(event) { var image_file_name = $(this).attr('image_file_name'); jQuery.ajax("cancelimage.php?fileImage=" + image_file_name) .done(function(data) { $(".imagemsg" + _cancelimagecounter).html(data); }); return stopImageUpload(); }); \[/code\]Below is the cancelimage.php page where the cancel button navigates to in order to be able to delete the database row:\[code\]<?php...$image_file_name = $_GET["fileImage"]; echo "File Upload was Canceled"; $imagecancelsql = "DELETE FROM Image WHERE ImageFile = 'ImageFiles/". mysql_real_escape_string($image_file_name)."'"; mysql_query($imagecancelsql); mysql_close();?>\[/code\]