How to get tmp name in ajax jQuery file?
<p>I am uploading image through ajax and during the ajax call, I want to set tmp name of uploaded file, but it returns <code>undefined</code>.</p>

<p>This is my code:</p>

<pre class="lang-js prettyprint-override"><code>function imageIsLoaded(e) {
  $("#file").css("color", "red");
  $('#image_preview').css("display", "block");
  $('#previewing').attr('src', e.target.result);
  //$('#previewing').attr('src', imagetempname);
  $('#previewing').attr('width', '150px');
  $('#previewing').attr('height', '150px');
  //alert(e.target.result);
};

$("#file").change(function() {
  $("#message").empty(); // To remove the previous error message
  var file = this.files[0];
  var imagefile = file.type;
  var imagename = file.name;
  var imagetempname = file.tmp_name;
  var match = ["image/jpeg", "image/png", "image/jpg"];
  if (!((imagefile == match[0]) || (imagefile == match[1]) || (imagefile == match[2]))) {
    $('#previewing').attr('src', 'noimage.png');
    $("#message").html("&lt;p id='error'&gt;Please Select A valid Image File&lt;/p&gt;" + "&lt;h4&gt;Note&lt;/h4&gt;" + "&lt;span id='error_message'&gt;Only jpeg, jpg and png Images type allowed&lt;/span&gt;");
    return false;
  } else {
    var reader = new FileReader();
    reader.onload = imageIsLoaded;
    reader.readAsDataURL(this.files[0]);
    document.getElementById("imagename").value = imagename;

    alert(imagetempname);
    document.getElementById("imagetmpname").value = imagetempname;
  }
});
</code></pre>

<p>Here when I <code>alert(imagetempname);</code>, it will return <code>undefined</code>.</p>