<script src="../../Scripts/js/jquery.form.min.js" type="text/javascript"></script>
function upLoadImg() {
var options = {
url: '/Home/AjaxUploadImg?',
type: 'post',
dataType: "text",
success: function (data) {
$("#addImgShow").append("<img src='" + data + "' style=' width:100px; height:100px; margin-right:3px;'/>");
//上传结束后清空file 否则继续上传同一张图会失败
$("#ImgInput").val("");
},
error: function () { alert("Error"); }
};
$('#upImgForm').ajaxSubmit(options);
}
<form id="upImgForm" name="upImgForm" action="" method="post" enctype="multipart/form-data" class="ifu">
<input type="hidden" id="hblogID" name="hBologID" value="" />
<input type="hidden" id="blogType" name="blogType" value="2" />
<input id="ImgInput" name="ImgInput" type="file" value="" onchange="upLoadImg()" style="height:35px; margin-top:-8px;" />
</form>