Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7973491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:07:12+00:00 2026-06-04T08:07:12+00:00

I have a cancel button where the user can cancel on a file upload

  • 0

I have a cancel button where the user can cancel on a file upload and it will display a cancel message. Now what I want also to happen is that when the user clicks on the Cancel button, it will look up for the file name which has been cancelled in the database and delete the database row. Problem is that it is not deleting the database row at all. How can I get this to happen. At the moment I am using the jpuery.ajax method which you can see in code below.

Below is form code:

var $fileImage = $("<form action='imageupload.php' method='post' enctype='multipart/form-data' target='upload_target' onsubmit='return imageClickHandler(this);' class='imageuploadform' >" + 

 "Image File: <input name='fileImage' type='file' class='fileImage' /></label><br/><br/><label class='imagelbl'>" + 

 "<input type='submit' name='submitImageBtn' class='sbtnimage' value='Upload' /></label>" + 

 "</p><p class='imagef1_cancel' align='center'><label>" + 

 "<input type='button' name='imageCancel' class='imageCancel' cancel_image_file_name='" + imagefilename + "' value='Cancel' /></label></form>"); 

Below is the cancel button function:

    $('.imagef1_cancel').eq(window.lastUploadImageIndex).find(".imageCancel").on("click", function(event) {

        var cancel_image_file_name = $(this).attr('cancel_image_file_name');

    jQuery.ajax("cancelimage.php?imagefilename=" + cancel_image_file_name)

    return stopImageUpload(2, cancel_image_file_name);

});

Finally below is the cancelimage.php script where the jquery.ajax navigates to, to supposedly be able to delete the the database row containing the file name:

 <?php

...

    //I have connected to database

    $cancel_image_file_name = $_GET["imagefilename"];

            $imagecancelsql = "DELETE FROM Image 
            WHERE ImageFile = 'ImageFiles/". mysql_real_escape_string($cancel_image_file_name)."'";

        mysql_query($imagecancelsql);

        mysql_close();


    ?>

UPDATE:

Below is what it currently shows when I echo the delete query:

Notice: Undefined index: imagefilename in /web/stud/xxx/…/cancelimage.php on line 19
DELETE FROM Image WHERE ImageFile = ‘ImageFiles/’

Below is the code of the delete function where when the Delete Button is pressed, it will navigate to the deleteimage.php script and delete the database row:

function stopImageUpload(success, imagefilename){

         $('.listImage').eq(window.lastUploadImageIndex).append('<div>' + htmlEncode(imagefilename) + '<button type="button" class="deletefileimage" image_file_name="' + imagefilename + '">Remove</button><br/><hr/></div>'); 

$('.listImage').eq(window.lastUploadImageIndex).find(".deletefileimage").on("click", function(event) {
    var image_file_name = $(this).attr('image_file_name');

    jQuery.ajax("deleteimage.php?imagefilename=" + image_file_name)

    $(this).parent().remove();
});

      return true;   
}

Below is deleteimage.php script:

<?php

//connected to DB

  $image_file_name = $_GET["imagefilename"];

        $imagedeletesql = "DELETE FROM Image 
        WHERE ImageFile = 'ImageFiles/". mysql_real_escape_string($image_file_name)."'";

    mysql_query($imagedeletesql);

    mysql_close();


?>

Below is an UPDATE of what the cancel button function now looks like:

function startImageUpload(imageuploadform, imagefilename){
            $('.imagef1_cancel').eq(window.lastUploadImageIndex).find(".imageCancel").on("click", function(event) {

var cancel_image_file_name_ = $(this).attr('css');
var cancel_image_file_name = '';
var style_array = cancel_image_file_name_.split(" ");
for(i=0;i<style_array.length;i++){
    if(style_array[i].substr(0,2) == "__"){
     cancel_image_file_name = style_array[i].slice(2,style_array[i].length-2);
}

}

    jQuery.ajax("cancelimage.php?imagefilename=" + cancel_image_file_name)

    return stopImageUpload(2, cancel_image_file_name);

});       
      return true;
}

I changed the button input tag to this for cancel button:

<input type='button' name='imageCancel' class='imageCancel __"+ imagefilename + "' value='Cancel' />
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:07:14+00:00Added an answer on June 4, 2026 at 8:07 am

    Try these changes:

    on form:

    <input type='button' name='imageCancel' class='imageCancel __"+ imagefilename + "' value='Cancel' /></label></form>
    

    on cancel button function:

    var cancel_image_file_name_ = $(this).attr('class');
    var cancel_image_file_name = '';
    var style_array = cancel_image_file_name_.split(" ");
    for(i=0;i<style_array.length;i++){
        if(style_array[i].substr(0,2) == "__"){
         cancel_image_file_name = style_array[i].slice(2,style_array[i].length);
    }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Cancel button which appears when the user is uploading a file.
I have a a form which contains a file input, upload button and cancel
I have a cancel button on a page. But this page can be opened
I have asp.net web site in which user can login and also do logout
I have a userform that is opened when a user clicks a button in
I have an alert that asks user if he/she want a picture from Photo
I have an NSManagedObject with attributes that a user can edit with a view.
I have a button click event that executes a group of file copy operations.
I'm trying to have a Cancel button send the user to the previous view
I have a cancel button which should bring the user back to the start

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.