Ajax allows you to upload files without refreshing the new upload function.
This article provides examples to share with you the specific code for implementing the File Upload without refreshing ajax function for your reference. The specific content is as follows:
The Code is as follows:
<! Doctype html>
Backend php code post_file.php
<? Phpheader ('content-type: text/html; charset = "UTF-8" '); $ upload_dir = 'uploads /'; if (strtolower ($ _ SERVER ['request _ method'])! = 'Post') {exit_status (array ('code' => 1, 'msg '=> 'incorrect submission method');} 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 '=> 'uploaded successfully', 'url' => $ upload_dir. $ pic ['name']);} echo $ _ FILES ['file'] ['error']; exit_status (array ('code' => 1, 'msg '=>' some errors occur '); function exit_status ($ s Tr) {echo json_encode ($ str); exit ;}?>
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.