使用JS获取当前页面input type=file 的真实路径

$(document).on(‘change’, ‘#PictureUrl’, function () { //PictureUrl为input file 的id
//console.log(this.files[0]);
function getObjectURL(file) {
var url = null;
if (window.createObjcectURL != undefined) {
url = window.createOjcectURL(file);
} else if (window.URL != undefined) {
url = window.URL.createObjectURL(file);
} else if (window.webkitURL != undefined) {
url = window.webkitURL.createObjectURL(file);
}
return url;
}
var objURL = getObjectURL(this.files[0]);//这里的objURL就是input file的真实路径
$(’#imgContainer’).html("Alternate Text");
cutImg();//自定义的裁剪图片函数
});

猜你喜欢

转载自blog.csdn.net/weixin_41612889/article/details/89185576