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 7910373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:50:47+00:00 2026-06-03T12:50:47+00:00

I have a Cancel button where when the user clicks on it, it resets

  • 0

I have a “Cancel” button where when the user clicks on it, it resets the source and removes the iframe so that the file does not get uploaded into the server after the user has clicked on the “Cancel” button. This is working fine.

But the problem I have is that also after the user has clicked on the “Cancel” button, I dont want it to insert the row into the database. But as that I have stated that if file is uploaded then insert a row into the database displaying the file name, then what I was thinking of doing was that if the “Cancel” button was clicked on, then it will navigate to the “cancelimage.php” page where it will delete the row. So technically the row is inserted and then deleted if the “Cancel” button is clicked on.

The problem is that it is not deleting the row, it is only inserting the row. How can I get it to delete the row in the database?

Below is the startImageUpload() function where it starts uploading and where the cancel button function is featured:

function startImageUpload(imageuploadform){

$(".imageCancel").on("click", function(event) {

              $("iframe[name='upload_target']").attr("src", "javascript:'<html></html>'");
          return stopImageUpload();

    jQuery.ajax("cancelimage.php")

});       
      return true;
}

Below is the code where it contains the upload script (imageupload.php) where it inserts a row into the database:

<?php

session_start();


$username="xxx";
$password="xxx";
$database="xxx";

mysql_connect('localhost',$username,$password);

mysql_select_db($database) or die( "Unable to select database");

$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();

?>

finally below is the cancelimage.php page where it is suppose to delete the 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");

    echo "File Upload was Canceled";

        $imagecancelsql = "DELETE FROM Image 
        WHERE ImageFile = 'ImageFiles/". mysql_real_escape_string($_FILES['fileImage']['name'])."'";

    mysql_query($imagecancelsql);

    mysql_close();


?>
  • 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-03T12:50:48+00:00Added an answer on June 3, 2026 at 12:50 pm

    When you call cancelimage.php $_FILES['fileImage']['name'] will not contain the name anymore. It only contains the file name at the page where it is uploaded. You will need to store the name in a cookie, session or something else.


    Edit:

    Never ever trust the input from a client:

    move_uploaded_file($_FILES["fileImage"]["tmp_name"],
    "ImageFiles/" . $_FILES["fileImage"]["name"]);

    What if I uploaded something with the filename ‘../imageupload.php’. Your site would be broken 😉 Even worse, I could inject all sorts of nasty code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a userform that is opened when a user clicks a button in
I have a a form which contains a file input, upload button and cancel
I have a UISearchDisplayController that shows the cancel button. I would like to call
I have to display a popup when user clicks on Place button inside a
I have a problem when the user has clicked on the Cancel button. When
In the dialog form below, I have 2 buttons: Save & Cancel. When user
I have a cancel button in a form: @using (Html.BeginForm(ConfirmBid,Auction)) { some stuff ...
I have a cancel button on a page. But this page can be opened
I have a form, this form has a submit and a cancel button. when
I have two buttons in my first android frame. ok button and cancel button.

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.