js表单提交,支持图片上传

来源:互联网 发布:如何获取股票数据 编辑:程序博客网 时间:2024/06/07 21:01
<html>
<head>
<meta http-equiv="Content-Type" content="charset=utf-8" />
<title>图片上传成功</title>
</head>
<body>
<form name="myupload" id="myupload" enctype='multipart/form-data' action="http://123.207.41.93/jtct/index.php/Program/GoodsShow/goods_add" method="post">
<input type="hidden" class="form-control" name="program_id" value="2">
<input type="text" name="goods_title" class="form-control" id="firstname">
<input type="file" value="fdfdfdf" name="image01" id="image01" onchange="setImagePreview();">
<input name="" id="" value="提交" type="submit" onclick="gosubmit2()" />
</form>
<script type="text/javascript ">
var files = $('.files');
function gosubmit2() {
$("#myupload ").ajaxSubmit({
dataType: 'json',
success: function(data) {
alert(data);
},
error: function(err) {
alert(err)
}
});
}
</script>
</body>
</html>