There is something I am trying to acheive but I don't quite understand how to do it. What I think I need to do is to pass the name of the image as a parameter to the cancelimage.php script and the use that in the query. But I don't think I am doing this with var image_file_name. What do I need to do to achieve this?
Below is the startImageUpload() function where it starts uploading an image and where the cancel button exist:
function startImageUpload(imageuploadform){
...
$(".imageCancel").on("click", function(event) {
var image_file_name = $(this).attr('image_file_name');
jQuery.ajax("cancelimage.php" + image_file_name)
.done(function(data) {
$(".imagemsg" + _cancelimagecounter).html(data);
});
return stopImageUpload();
});
return true;
}
Below is the cancelimage,php page where it is suppose to delete a row from the database?
<?php
$username="xxx";
$password="xxx";
$database="xxx";
mysql_connect('localhost',$username,$password);
mysql_select_db($database) or die( "Unable to select database");
$image_file_name = $_GET["fileImage"]["name"];
echo "File Upload was Canceled";
$imagecancelsql = "DELETE FROM Image
WHERE ImageFile = 'ImageFiles/". mysql_real_escape_string($image_file_name)."'";
mysql_query($imagecancelsql);
mysql_close();
?>