Get Full Path Image Into Input File
I want get the full path image from input file for show image preview and use for example attr of jquery for insert this into scr to this temporal image path , for example i think
Solution 1:
MOZILLA DEVELOPER NETWORK show us an example to do that:
<inputtype="file"id="fileElem"multipleaccept="image/*"style="display:none"onchange="handleFiles(this.files)"><ahref="#"id="fileSelect">Select some files</a><divid="fileList"><p>No files selected!</p></div><script>window.URL = window.URL || window.webkitURL;
var fileSelect = document.getElementById("fileSelect"),
    fileElem = document.getElementById("fileElem"),
    fileList = document.getElementById("fileList");
fileSelect.addEventListener("click", function (e) {
  if (fileElem) {
    fileElem.click();
  }
  e.preventDefault(); // prevent navigation to "#"
}, false);
functionhandleFiles(files) {
  if (!files.length) {
    fileList.innerHTML = "<p>No files selected!</p>";
  } else {
    var list = document.createElement("ul");
    for (var i = 0; i < files.length; i++) {
      var li = document.createElement("li");
      list.appendChild(li);
      var img = document.createElement("img");
      img.src = window.URL.createObjectURL(files[i]);
      img.height = 60;
      img.onload = function(e) {
        window.URL.revokeObjectURL(this.src);
      }
      li.appendChild(img);
      var info = document.createElement("span");
      info.innerHTML = files[i].name + ": " + files[i].size + " bytes";
      li.appendChild(info);
    }
    fileList.appendChild(list);
  }
}
</script>HERE the Mozilla DOC.
HERE some problem to do that.
Post a Comment for "Get Full Path Image Into Input File"