Skip to content

Instantly share code, notes, and snippets.

@tingwei628
Created July 2, 2015 01:41
Show Gist options
  • Save tingwei628/ebebd51a31498c421af5 to your computer and use it in GitHub Desktop.
Save tingwei628/ebebd51a31498c421af5 to your computer and use it in GitHub Desktop.
[JavaScript] 本地預覽圖片(ExtJS)
/*
設image 的本地預覽圖片路徑 url
*/
function setImageSrc() {
var url = '',
file = filefield.fileInputEl.dom.files[0];
if (window.createObjectURL) {
url = window.createObjectURL(file);
} else if (window.URL) { // mozilla(firefox)
url = window.URL.createObjectURL(file);
} else if (window.webkitURL) { // webkit or chrome
url = window.webkitURL.createObjectURL(file);
}
image.setSrc(url);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment