Home>Article>Backend Development> How to implement PHP+Ajax to dynamically display the progress of uploading files
Let me make a premise:
The PHP configuration file stipulates that the default upload file size limit is less than 2M. If you need to upload large files, you need to change the upload_max_filesize and upload_max_filesize in php.ini at the same time. The values of max_execution_time and post_max_size.
Related recommendations: "PHP Tutorial"
Main interface and Ajax implementation:
index.html
上传文件 Ajax实现进度条文件上传
php handles uploads File: upload.php
0) { exit("上传文件有错".$_FILES['userfile']['error']); } // 定义存放上传文件的真实路径 $path = './upload/'; // 定义存放上传文件的真实路径名字 $name = $_FILES['userfile']['name']; // 将文件的名字的字符编码从UTF-8转成GB2312 $name = iconv("UTF-8", "GB2312", $name); // 将上传文件移动到指定目录文件中 if (move_uploaded_file($_FILES['userfile']['tmp_name'], $path.$name)) { echo "文件上传成功"; } else { echo "文件上传失败"; } ?>
The above is the detailed content of How to implement PHP+Ajax to dynamically display the progress of uploading files. For more information, please follow other related articles on the PHP Chinese website!