title: Javascript get file name is not working
body: <p>Firstly i'll need to apologize as I'm <strong>very new</strong> to coding and this might be very easy to be solved </p>
  
  <p>I need to get the name of the file and display it within the blue box. My js script's last part does not work: </p>
  
  <pre><code>var filename = e.target.value.split('\\').pop();    
  $("#label_span").text(filename);
  </code></pre>
  
  <p>The message below was displayed when I tried it using the codesnippet</p>
  
  <blockquote>
    <p>{
      "message": "Uncaught ReferenceError: e is not defined",
      "filename": "<a href="https://stacksnippets.net/js" rel="nofollow noreferrer">https://stacksnippets.net/js</a>",
      "lineno": 109,
      "colno": 19
    }</p>
  </blockquote>
  
  <p>Thanks in advance!</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
    $("#file").on("change", function() {
      var files = $(this)[0].files;
  
      if (files.length &gt;= 2) {
        $("#label_span").text(files.length + " files ready to upload");
      } else {
        var filename = e.target.value.split('\\').pop();
        $("#label_span").text(filename);
      }
    });
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>body {
    font-family: 'Varela Round', sans-serif;
    font-family: 16px;
  }
  
  h1 {
    color: #3c4954;
    text-align: center;
    margin-top: 100px;
    font-size: 36px;
  }
  
  p {
    color: #a4b0b9;
    line-height: 200%;
  }
  
  * {
    box-sizing: border-box;
  }
  
  footer {
    position: absolute;
    width: 100%;
    bottom: 20px;
  }
  
  .form-div {
    margin-top: 100px;
  }
  
  .input-label {
    background: #009688;
    color: #fff;
    padding: 30px;
    cursor: pointer;
  }
  
  .input-label:hover {
    background: #26a69a;
    cursor: white;
    cursor: pointer;
    padding: 30px;
    transition: .2s;
  }
  
  .fa {
    margin-right: 10px;
  }
  
  #file {
    display: none;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"&gt;&lt;/script&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Custom Input&lt;/title&gt;
    &lt;link href='https://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'&gt;
    &lt;link rel="stylesheet" href="Test_Impor.css" /&gt;
    &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"&gt;
    &lt;script src="http://code.jquery.com/jquery-1.11.0.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body align="center"&gt;
    &lt;header&gt;
      &lt;h1&gt;Custom Input&lt;/h1&gt;
    &lt;/header&gt;
    &lt;div class="form-div"&gt;
      &lt;form&gt;
        &lt;label for="file" class="input-label"&gt;
       &lt;i class = "fa fa-upload"&gt;&lt;/i&gt;
       &lt;span id = "label_span"&gt;Select files to upload&lt;/span&gt;
      &lt;/label&gt;
        &lt;input id="file" type="file" multiple="true" /&gt;
      &lt;/form&gt;
    &lt;/div&gt;
    &lt;script src="Test_Import.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>