文件上传在我的程序中运行良好,但只有在刷新页面之后。
Javascript
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>Assets/Scripts/ajaxfileupload.js"></script>
<script type="text/javascript">
function ajaxFileUpload(){
$("#loading")
.ajaxStart(function(){
$(this).show();
})
.ajaxComplete(function(){
$(this).hide();
});
$.ajaxFileUpload
(
{
url:'<?php echo site_url()?>/welcome/doupload',
secureuri:false,
fileElementId:'fileToUpload',
dataType: 'json',
success: function (data, status){
if(typeof(data.error) != 'undefined'){
if(data.error != ''){
$("#info").html(data.error);
} else {
$("#info").html(data.msg);
}
}
},
error: function (data, status, e){
$("#info").html(e);
}
}
)
return false;
}
</script>