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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:10:27+00:00 2026-06-12T01:10:27+00:00

I have a table where it appends rows and that I have 3 rows,

  • 0

I have a table where it appends rows and that I have 3 rows, the table below will look something like this:

  Question No     Image

    1            (file input)
    2            (file input)
    3            (file input)

Below is the code that creates the table above:

var qnum = 1;  
var numimage = 0;

var $qid = $("<td class='qid'></td>").text(qnum);
var $image = $("<td class='image'></td>"); 


          $('.num_questions').each( function() {

    var $this = $(this);

     var $questionNumber = $("<input type='hidden' class='num_questionsRow'>").attr('name',$this.attr('name')+"[]")
                   .attr('value',$this.val());

     $qid.append($questionNumber);  
    ++qnum;
    ++numimage;          
    $(".questionNum").text(qnum);
    $(".numimage").val(numimage);

});

    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>" + 
    "<input type='hidden' class='numimage' name='numimage' value='" + numimage + "' />" +
    "</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' name='upload_target' src='#' style='width:0;height:0;border:0px;solid;#fff;'></iframe></form>");        

    $image.append($fileImage);

   $tr.append($qid);
    $tr.append($image);

The problem I have is that if a file was unsuccessful or cancelled and then I upload another file which is this time successful, I recieve this notice below in my iframe:

Notice: Undefined index: numimage in /web/stud/...../app/imageupload.php on line 150

My question is that why do I recieve this notice in my php code below where it inserts data into database when I successfully upload a file after an unsuccessful attempt or cancellation?

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

 $lastID = $mysqli->insert_id;         

 $imagequestionsql = "INSERT INTO Image_Question (ImageId, SessionId, QuestionId)  
    VALUES (?, ?, ?)"; 

     if (!$insertimagequestion = $mysqli->prepare($imagequestionsql)) { 
      // Handle errors with prepare operation here 
       echo "Prepare statement err imagequestion"; 
    } 

$qnum = (int)$_POST['numimage'];

$insertimagequestion->bind_param("isi",$lastID, $sessid, $qnum); 

$sessid =  $_SESSION['id'] . ($_SESSION['initial_count'] > 1 ? $_SESSION['sessionCount'] : ''); 

    $insertimagequestion->execute(); 

                if ($insertimagequestion->errno) { 
          // Handle query error here 
        } 

        $insertimagequestion->close(); 

      }

<script language="javascript" type="text/javascript">window.top.stopImageUpload(<?php echo $result ? 'true' : 'false'; ?>, '<?php echo $_FILES['fileImage']['name'] ?>');</script>

UPDATE:

Below is the jquery code where it contains the startimageupload function for when uploading starts and the stopimageupload function for when uploading stops or is finished:

function htmlEncode(value) { return $('<div/>').text(value).html(); }

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');
sourceImageForm = imageuploadform;

$(".sbtnimage").attr("disabled", "disabled");
$(".sbtnvideo").attr("disabled", "disabled");
$(".sbtnaudio").attr("disabled", "disabled");

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

}

var imagecounter = 0;
function stopImageUpload(success, imagefilename){
var result = '';
imagecounter++;

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>');
}

else if (success == 2){

result = '<span class="imagemsg'+imagecounter+'"> The file upload was canceled</span><br/><br/>';

}

else {

result = '<span class="imagemsg'+imagecounter+'">There was an error during file upload</span><br/><br/>';
}

$(sourceImageForm).find('.imagef1_upload_process').css('visibility','hidden');
$(sourceImageForm).find('.imagef1_cancel').css('visibility','hidden');
$(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>');
$(sourceImageForm).find('.imagef1_upload_form').css('visibility','visible');

$(".sbtnimage").removeAttr("disabled");
$(".sbtnvideo").removeAttr("disabled");
$(".sbtnaudio").removeAttr("disabled");

$(".imageClear").on("click", function(event) {
event.preventDefault();
$(this).parents("form:first").find(".fileImage").replaceWith("<input type='file' class='fileImage' name='fileImage' />");
}); 
  • 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-12T01:10:29+00:00Added an answer on June 12, 2026 at 1:10 am

    Ok from looking at the code you’ve posted I’m making a guess as to what is happening because I can’t see the complete flow of the code. 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 I can infer, your 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 think I’m guessing right – that you 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='2' />
    

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

    Again as I say this is a guess, but it would lead to the removal of a field that did exist to start with, and would produce the problems you are seeing.

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

Sidebar

Related Questions

I have a table, that looks like this: <table class=sortabletable> <thead> <tr> <th style=width:
I have a script that appends some rows to a table. One of the
I have table with around 70 000 rows. There is 6000 rows that i
I have a form that adds rows to a table upon submit: <form id=scan_form
I have a table inside a form that looks as follows: <td><input type=text name=code[0]
Some sites have tables which appends rows when you scroll the browser so that
I can't seem to figure this out... I have a table with 'x' rows.
I have a very big MySQL table (millions of rows) that gets new data
I have table in which I am inserting rows for employee but next time
I have table and this table contain result column with some entries. I just

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.