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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:07:30+00:00 2026-06-12T05:07:30+00:00

Basically the following code is causing your problem: $(sourceImageForm).find(‘.imagef1_upload_process’).css(‘visibility’,’hidden’); $(sourceImageForm).find(‘.imagef1_cancel’).css(‘visibility’,’hidden’); /// THIS LINE BELOW

  • 0

Basically the following code is causing your problem:

$(sourceImageForm).find('.imagef1_upload_process').css('visibility','hidden'); 
$(sourceImageForm).find('.imagef1_cancel').css('visibility','hidden'); 
/// THIS LINE BELOW 
$(sourceImageForm).find('.imagef1_upload_form').html(result + '<label>Image File: <input name="fileImage" class="fileImage" type="file"/></label><br/><br/><label><input type="submit" name="submitImageBtn" class="sbtnimage" value="Upload" /></label><label><input type="button" name="imageClear" class="imageClear" value="Clear File"/></label>'); 
/// THIS LINE ABOVE 
$(sourceImageForm).find('.imagef1_upload_form').css('visibility','visible'); 

The above code is taken from the code that runs after a succesful/errorful upload has occured. This code proceeds to overwrite the form responsible for uploading the image. Now this is fine for successes because as the interface uses seperate forms for each image… once you get a success you don’t reuse that form again (so no error on the server side for subsequent uploads).

However, when the image upload errors or cancels,I try and reuse that form to upload the image again? If so you have overwritten and removed the numimage input html:

<input type='hidden' class='numimage' name='numimage' value='" numimage "' /> 

Which means that I would get an error as this field doesn’t exist anymore.

My question is that how can I fix this? How can I fix the problem so I don’t lose the value in the hidden input form and that the field still exists?

UPDATE:

Below is the image input form:

    var $fileImage = $("<form action='imageupload.php' method='post' enctype='multipart/form-data' target='upload_target_image' onsubmit='return imageClickHandler(this);' class='imageuploadform' >" + 
"<input type='hidden' class='numimage' name='numimage' value='" + numimage + "' />" +
"<div class='display_content_image'>" +
"<p class='imagef1_upload_process' align='center'>Loading...<br/><img src='Images/loader.gif' /><br/></p>" +
"<p class='imagef1_upload_form' align='center'><br/><label>" + 
"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='reset' name='imageCancel' class='imageCancel' value='Cancel' /></label>" +
"</p><p class='listImage' align='left'></p>" +
"<iframe class='upload_target_image' name='upload_target_image' src='#' style='width:300px;height:300px;border:0px;solid;#fff;'></iframe></div></form>");

$image.append($fileImage);

Below is the jquery code in full where it starts the image file upload:

function startImageUpload(imageuploadform){

  $(imageuploadform).find('.imagef1_upload_process').css('visibility','visible');
  $(imageuploadform).find('.imagef1_cancel').css('visibility','visible');
  $(imageuploadform).find('.imagef1_upload_form').css('visibility','hidden');
  $(imageuploadform).find('.imagef1_upload_form').find('.display_content_image').css('visibility','hidden');
  sourceImageForm = imageuploadform;

        $(imageuploadform).find(".imageCancel").on("click", function(event) {
                  $('.upload_target_image').get(0).contentwindow
              $("iframe[name='upload_target_image']").attr("src", "javascript:'<html></html>'");
    return stopImageUpload(2);

});      


  return true;

}

Below is the jquery code in full where it stops the image file upload:

function stopImageUpload(success, imagefilename){

      var result = '';
      imagecounter++;

      var replaceForm = function(result) { 
  $(sourceImageForm).find('.imagef1_upload_form').html(result + '<label>Image File: <input name="fileImage" class="fileImage" type="file"/></label><br/><br/><label><input type="submit" name="submitImageBtn" class="sbtnimage" value="Upload" /></label><label><input type="button" name="imageClear" class="imageClear" value="Clear File"/></label>');
} 

var updateForm = function(result) { 
  $(sourceImageForm).find('.imagef1_upload_form').find('.display_content_image').html(result);
} 

var displayInfo;

      if (success === 1){
         result = '<span class="imagemsg'+imagecounter+'">The file was uploaded successfully</span><br/><br/>';      
         $('.listImage').eq(window.lastUploadImageIndex).append('<div>' + htmlEncode(imagefilename) + '<button type="button" class="deletefileimage" image_file_name="' + imagefilename + '">Remove</button><br/><hr/></div>'); 
        displayInfo = replaceForm;      
         }
      else if (success === 2){
          result = '<span class="imagemsg'+imagecounter+'"> The file upload was canceled</span><br/><br/>';
          displayInfo = updateForm;    
      }
      else {
         result = '<span class="imagemsg'+imagecounter+'">There was an error during file upload</span><br/><br/>';
         displayInfo = updateForm;  
      }
      displayInfo(result); 


      $(sourceImageForm).find('.imagef1_upload_process').css('visibility','hidden');
      $(sourceImageForm).find('.imagef1_cancel').css('visibility','hidden');
      $(sourceImageForm).find('.imagef1_upload_form').css('visibility','visible');


    });
  • 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-12T05:07:32+00:00Added an answer on June 12, 2026 at 5:07 am

    This line:
    $(sourceImageForm).find('.imagef1_upload_form').html(...) is clobbering the contents of the form element. If the existing code works for success conditions then you should leave it as is. When you’re handling the error condition (ideally using the error callback if you have a RESTful API), rather than overridding the entire form you should have a specific element for the error message which is then populated. Something like:

    $(sourceImageForm).find('.imagef1_upload_form').find('.error_message').html(msg).show();

    Sample for update:

    var replaceForm = function(result) {
      //existing code to replace full form content
    }
    var updateForm = function(result) {
      //new code to display error message
    }
    var displayFunk;
    if (success === 1){
      result = '<span class="imagemsg'+imagecounter+'">The file was uploaded successfully</span><br/><br/>';      
      $('.listImage').eq(window.lastUploadImageIndex).append('<div>' + htmlEncode(imagefilename) + '<button type="button" class="deletefileimage" image_file_name="' + imagefilename + '">Remove</button><br/><hr/></div>'); 
      displayFunk = replaceForm;
    }
    else if (success === 2){
      result = '<span class="imagemsg'+imagecounter+'"> The file upload was canceled</span><br/><br/>';
      displayFunk = updateForm;
    }
    else {
      result = '<span class="imagemsg'+imagecounter+'">There was an error during file upload</span><br/><br/>';
      displayFunk = updateForm;
    }
    displayFunk(result);
    

    Notice the === for comparison which avoids some JavaScript automatic coercion. This will head off bugs when doing things like comparing a value to 1. You’d also be best off avoiding the way you’re using a return value, but at the least you may want to use pseudo constants/enum and a dispatch table style object.

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

Sidebar

Related Questions

I have a problem with the following scenario (code cut for brevity). Basically the
The following code basically works as expected. However, to be paranoid, I was wondering,
I'm struggling with the following code. Basically, I have a class Foo and nested
I write something similar to the following code a lot. It basically toggles an
I'm having an issue with rails involving javascript. Basically, I have the following code:
I'm trying to translate the following JS code to ObjC; It basically defines a
My problem can be reduced to basically the following set of entities : I
When I run the following code it basically works how I intend it to,
My AS3 application basically does the following (pseudo code from main application class) 3
I have the following code, which basically takes values from a database and populates

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.