<form id="form1" target="nm_iframe" action="http://api.bgmc2c.com/index.php?service=UserAction.Edit_user_info" method="post" enctype="multipart/form-data">
<div class="head_pic_box headdiv"><img src="img/camera.png" id="sel_head_pic"/></div>
<input type="file" name="file" id="file"/>
<input type="submit" value="上傳" id="sub_file"/>
</form>
<!--讓上傳文件表單的內容消失-->
<iframe id="id_iframe" name="nm_iframe" frameborder="0" style="display: none;"></iframe>php
//jquery代碼jquery
$(".headdiv").on("tap","#sel_head_pic",function(e){
e.preventDefault();
e.stopPropagation();
$("#file").click();
})ajax
//這段做用是在頁面上替換頭像圖片
var x=new FileReader
var file=document.getElementById("file")
file.onchange=function(){
x.readAsDataURL(this.files[0]);
}
x.onloadend=function(){
headpic.src=this.result;
}api
$("#form1").on("tap","#sub_file",function(){
if($("#file").val()!==''){
}post
//jquery 表單提交插件
$("#form1").ajaxSubmit(function(data){
})
})this