How to upload files with ajax without refreshing

php中世界最好的语言
Release: 2018-03-31 10:56:14
Original
1390 people have browsed it

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

    ajax无刷新上传文件  
Copy after login
Backend

php 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; } ?>
Copy after login
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!