<!--上传图片-->
<div class="img_box">
<h5><span>*</span>上传截图</h5>
<div class="camera_box">
<img src="../images/camera.png"/>
<input style="color: #7f88a6" type="file" id="upload" class="set-file" accept="image/*">
</div>
<div id="img" style="float: left;"></div>
</div>
//上传图片
var pic;
$('#upload').change(function(){
var file = $(this)[0];
var formData = new FormData();
formData.append('file', file.files[0]);
$.ajax({
url:"/index/Upload/uploadImg",
type: 'POST',
data: formData,
async:false,
contentType: false, // 注意这里应设为false
processData: false,
success: function(res){
console.log(res);
pic = res.data;
$('#img').append('<img src="'+res.data+'" class="img_zm" style="width:2rem;height:2rem;">');
$(".camera_box").hide();
},
error: function(XHR, textStatus, errorThrown) {
alert("网络连接失败!!!");
}
});
});
//多张图片
$('#upload').change(function(){
var file = $(this)[0];
var formData = new FormData();
formData.append('file', file.files[0]);
$.ajax({
url:"/index/Upload/uploadImg",
type: 'POST',
data: formData,
async:false,
contentType: false, // 注意这里应设为false
processData: false,
success: function(res){
//console.log(res);
if(res.code=="0"){
var bq_length = $("#img .upload_img").length;
console.log(bq_length)
if(bq_length<=2){
$('#img').append('<div class="upload_img" style="position: relative;float:left;">'+
'<img src="'+res.data+'" class="img_zm" style="width:1.5rem;height:1.5rem;float:left;margin:0.3rem 0 0 0.24rem">'+
// '<img style="width: 0.3rem;height: 0.3rem;position: absolute;top: 0.24rem;right: 0" src="../img/delete.png">'+
'</div>');
}
if(bq_length >= 2){
$(".rg-sc").hide();
}
}
},
});
});