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

  • Home
  • SEARCH
  • 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 7518755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:47:40+00:00 2026-05-30T01:47:40+00:00

I am working on an image upload site. When the user uploads the images

  • 0

I am working on an image upload site. When the user uploads the images with no problems, it save the image in 4 different sizes inside 4 different folders. After that, they are redirected to same page with new content. Now they are going to crop the image. The Image crop functions work fine. I’ve made a function to check if the user leaves the site. If they do, the 3 functions will delete the 4 stored images by an AJAX script.

Code:

function unfinished(album, img) {
    window.onbeforeunload = function(e) {
        e = e || window.event;
        var response = '';
        var xmlhttp;
        if (window.XMLHttpRequest) {
            // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        } else {
            // code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                response = xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET", "incl/unfinished.php?a=" + album + "&i=" + img, true);
        xmlhttp.send();
        // For IE and Firefox prior to version 4
        if (e) {
            e.returnValue = response;
        }
        // For Safari
        return response;
    }
}

My problem is, that this function is also triggered when they click the “save crop” button. And of course it’s not what I want.

Any solutions to how to make the function not popup when the save button is clicked?

If it matters, I run the unfinished function by:

onload='onfinished("$nameonalbum","Filename")'

My save crop html code:

input type="submit" name="upload_thumbnail" value="Save crop" id="save_thumb"

Any help is welcome. Thank you for the patience and understanding.

  • 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-05-30T01:47:41+00:00Added an answer on May 30, 2026 at 1:47 am

    I had to do something similar to you in one case, so I created a variable unload = true and the start of the page, and then instead of doing <input type="submit" I changed it to <input type="button" onclick="runFunction();" and then in my

    function runFunction() {
    unload = false;
    $('#form').submit();
    };
    

    then I would add if(unload) { ...do stuff here } in the onBeforeUnload()

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

Sidebar

Related Questions

I am working on a php site in which we have to upload images
I am using WebTechNick's file upload plugin to save images on my CakePHP site.
I'm working on an MVC site with an image upload capability and I want
A site I am currently working with allows users to upload images onto a
I'm working the the image upload piece of the FCKEditor and I've got the
Could you please help me to get image upload working on a view with
Okay so im working on this php image upload system but for some reason
I am working on a site that needs to display inventory data. I am
I have an application that allows users to upload images. The test case I
I have used a input file code to upload image to my wallpaper site..

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.