html+php實現無刷新上傳文件
阿新 • • 發佈:2017-08-11
簡單 upload post move play llb cti == none
親測好用!!!代碼示例是上傳excel
html代碼
<form id="uploadForm" class="picForm" action="finance.php?act=excel" method="post" enctype="multipart/form-data" target="hiddenIFrame">
<input type="file" class="excel" name="excel" style="border-radius: 5px;">
</form>
<iframe id=‘hiddenIFrame‘ name=‘hiddenIFrame‘ style="display:none;"></iframe>
js代碼(jq)
$(function(){
$("#hiddenIFrame").load(function(){
var wnd = this.contentWindow;
var str = $(wnd.document.body).html();
callback(str);
});
})
function callback(info){
if(info==1)
{
alert(‘請選擇正確的格式‘);
}
}
$(".excel").change(function(){
var _this=$(this);
$("#uploadForm").submit();
})
php代碼
這邊的代碼就是簡單的move_upload_file
html+php實現無刷新上傳文件