js 獲取input file路徑改變圖像地址


已轉至:http://blog.csdn.net/sangjinchao/article/details/52250318

 

html代碼

<img id="newImage" alt="100x100" src="__PUBLIC__/img/1.jpg" class="img-circle" width="100px" height="100px" >

<input id="image" type='file' name='myFile' size='15' onchange="showPicture(this)"/>

 

js代碼

function showPicture(imgFile){
// alert(window.URL.createObjectURL(imgFile.files[0]));
/*獲取上傳文件的路徑*/
document.getElementById("newImage").src = window.URL.createObjectURL(imgFile.files[0]);
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM