Created
July 2, 2015 01:41
-
-
Save tingwei628/ebebd51a31498c421af5 to your computer and use it in GitHub Desktop.
[JavaScript] 本地預覽圖片(ExtJS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
設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