How to define this variable below?
<p>I have a Cancel button which appears when the user is uploading a file. If the user wishes to cancel a file upload then they can by clicking on the Cancel Button and it would display the cancel message to user. </p>

<p>The only problem when attempting this is that it is stating that cancel_image_file_name is undefined in the stopImageUpload function where I want to display the message. But I did define this in the startImageUpload function. So my question is that how can I grab cancel_image_file_name from the startImageUpload function and define it in the stopImageUpload function?</p>

<p>Below is the code showing the 2 functions:</p>

<p>startImageUpload function: </p>

<pre><code>var cancelimagecounter = 0;

function startImageUpload(imageuploadform, imagefilename){

    cancelimagecounter++;

            var _cancelimagecounter = cancelimagecounter;

    $('.imageCancel').on("click", function(event) {
        var cancel_image_file_name = $(this).attr('cancel_image_file_name');

    return stopImageUpload(2, cancel_image_file_name);

});       
      return true;
}
</code></pre>

<p>stopImageUpload function: </p>

<pre><code>var imagecounter = 0;

function stopImageUpload(success, imagefilename){

      var result = '';
      imagecounter++;

      if (success == 1){
         result = '&lt;span class="imagemsg'+imagecounter+'"&gt;The file was uploaded successfully!&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;';      
         $('.listImage').eq(window.lastUploadImageIndex).append('&lt;div&gt;' + htmlEncode(imagefilename) + '&lt;button type="button" class="deletefileimage" image_file_name="' + imagefilename + '"&gt;Remove&lt;/button&gt;&lt;br/&gt;&lt;hr/&gt;&lt;/div&gt;'); 
      }
      else if (success == 2){
          result = '&lt;span class="imageemsg"&gt;' + cancel_image_file_name + ' Upload Was Cancelled!&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;';
      }
      else {
         result = '&lt;span class="imageemsg"&gt;There was an error during file upload!&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;';
      }


      return true;   
}
</code></pre>
