angular +H5 上传图片 与预览图片
2021-07-01 15:06
标签:identity script card ng-model sub conf default button dex service.js 3:controller.js 照片的预览 angular +H5 上传图片 与预览图片 标签:identity script card ng-model sub conf default button dex 原文地址:http://www.cnblogs.com/mamimi/p/7132074.html//index.html
var uploadFile = function(dataParam,successFn,errFun){
$http({
method: ‘POST‘,
url: configuration.apiBaseUrl+‘/api/tms/upload/uploadFile‘,
data: dataParam,
headers: {‘Content-Type‘: undefined},
transformRequest: angular.identity
}).success(function (data) {
if(typeof successFn ===‘function‘){
successFn(data);
}
}).error(function (data) {
if(typeof errFun === ‘function‘){
errFun(data);
}
});
};
function save(frontIdCard,backIdCard,photoDriverCard) {
var fd = new FormData();
if(frontIdCard){
fd.append("frontIdCard", frontIdCard);
}
if(backIdCard){
fd.append("backIdCard", backIdCard);
}
if(photoDriverCard){
fd.append("photoDriverCard", photoDriverCard);
}
myCarService.uploadFile(fd, function (data) {
var fileArr = data.content;
for(var i=0; i
$scope.previewImage = function(fileId, imgId) {
var preview = document.querySelector("#" + imgId);
var file = document.querySelector("#" + fileId).files[0];
var reader = new FileReader();
reader.onloadend = function () {
preview.src = reader.result;
}
if (file) {
reader.readAsDataURL(file);
} else {
preview.src = "http://www.soscw.com/images/noimg.png";
}
};
文章标题:angular +H5 上传图片 与预览图片
文章链接:http://soscw.com/index.php/essay/100372.html