$("#fileUpload1").change(function () {
var files =$("#fileUpload1")[0].files[0]
var urls = getObjectURL(files)
$("#fileList1").empty();
$("#fileList1").append(
'<embed src="'+urls+'" type="application/pdf">'
// '<img src="'+urls+'" height="50px" alt="">'
)
console.log(files,urls);
});
function getObjectURL(file) {
// 获取图片上传的本地地址
var url = null ;
if (window.createObjectURL!=undefined) { // basic
url = window.createObjectURL(file) ;
} else if (window.URL!=undefined) { // mozilla(firefox)
url = window.URL.createObjectURL(file) ;
} else if (window.webkitURL!=undefined) { // webkit or chrome
url = window.webkitURL.createObjectURL(file) ;
}
return url ;
}
网友评论