This time I will show you how to upload files with ajax without refreshing. What are theprecautions for uploading files with ajax without refreshing? The following is a practical case, let's take a look.
The example in this article shares the specific code for ajax to implement the function of uploading files without refreshing for your reference. The specific content is as follows The detailed code is as follows Backendphp codepost_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; } ?>
How to implement WebApi Ajax cross-domain request using CORS
How to implement dynamic loading of combo box with Ajax (With code)
The above is the detailed content of How to upload files with ajax without refreshing. For more information, please follow other related articles on the PHP Chinese website!