本文主要为大家详细介绍了ajax实现无刷新上传文件功能,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,希望能帮助到大家。
详细代码如下
ajax无刷新上传文件
后端php代码post_file.php
1,'msg'=>'错误提交方式'));
}
if(array_key_exists('file',$_FILES) && $_FILES['file']['error'] == 0 ){
$pic = $_FILES['file'];
if(move_uploaded_file($pic['tmp_name'], $upload_dir.$pic['name'])){
exit_status(array('code'=>0,'msg'=>'上传成功','url'=>$upload_dir.$pic['name']));
}
}
echo $_FILES['file']['error'];
exit_status(array('code'=>1,'msg'=>'出现了一些错误'));
function exit_status($str){
echo json_encode($str);
exit;
}
?>相关推荐:










