The reason why it is difficult to implement an upload progress bar in PHP is because when we upload files to the server, we have to wait until all files are sent to the server before executing the corresponding PHP file. Before this, the file data was saved in a temporary file, and PHP could not obtain the path and size of this file.
Starting from Actionscript 2.0, Flash supports file upload and download. Although we cannot get the file upload progress on the server side, we can get the file sending progress on the server side. Based on this principle, you can use Flash to create an upload progress bar effect.
I have seen some information on the Internet, but I feel it is flawed. So I did some research myself, strengthened the security and robustness of the program on the basis of predecessors, and added some customizable parameters.
Note: If your computer has firewall software installed, you may see a progress bar that reaches 100% at once. This is because the progress bar shows the speed of flash transferring files to the firewall software! The firewall also passes the data to the server.
Please click here for demonstration
This program is improved by Longbill based on relevant information on the Internet
http://www.longbill.cn
Email: longbill.cn@gmail .com
Instructions for calling parameters (assuming the name of this flash is upload.swf):
Write the calling address of the flash file as:
upload.swf?maxsize=[Maximum size of a single file ]&bgcolor=[Progress bar color]
&limit=[Limit upload file type]&savefile=[Upload object file]
[Maximum size of a single file]: [Optional] [Number] (unit is KB )
[Progress bar color]: [Optional] [Six-digit hexadecimal number] [Default is random color] (16-bit color value without #)
[Restrict upload file type]: [Yes Select] format such as: limit=zip|rar|doc
[Upload object file]: [Default is save.php] [String]
For example:
upload.swf?maxsize=2048&bgcolor =FF00FF&limit=jpg|gif|png&savefile=upsave.php
Package file download