It keeps displaying undefined for file name
<p>I trying to display the name of the file after the user has uploaded it. The file uploads successfully but in the javascript it keeps displaying the message below:</p>

<blockquote>
  <p>The file (undefined) was uploaded successfully!</p>
</blockquote>

<p>It keeps displaying undefined when it should display the filename. Why is this? At the moment what is happening is that wen the user uploads the file, the files is uploaded into the "ImageFiles" folder, when uploading is finsihed the javascript function below displays the message to state the name of the file which has been successfully uploaded.</p>

<p>Below is the code which displays the file name and message after uploading:</p>

<pre><code>function stopImageUpload(success){

    function handleFileSelect(evt) {
    var files = evt.target.files;
    localStorage["fname"] = files[0].name; //save the name for future use
}

$('.fileImage').bind('change', handleFileSelect, false);


      var result = '';
      if (success == 1){
  result = '&lt;span class="msg"&gt;The file ('+localStorage["fname"]+') was uploaded successfully!&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;';
    localStorage["fname"] = undefined; //remove the temporary variable

      }
      else {
         result = '&lt;span class="emsg"&gt;There was an error during file upload!&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;';
      }

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

<p>Below is form:</p>

<pre><code>  &lt;form action='imageupload.php' method='post' enctype='multipart/form-data' target='upload_target' onsubmit='stopImageUpload(this);' class='imageuploadform' &gt;
    &lt;p&gt;Image File: &lt;input name='fileImage' type='file' class='fileImage' /&gt;
    &lt;input type='submit' name='submitImageBtn' class='sbtnimage' value='Upload' /&gt;
    &lt;/p&gt; 
    &lt;/form&gt;
</code></pre>
