ASP Upload progress bars reflect the upload status in real time
Source: Internet
Author: User
Asp when using components to upload, a little trouble is not know the upload progress is how much, although some provide the upload progress bar, such as abcupload (Download Address: http://www.websupergoo.com progress ), it is a progress page (progressbar. asp), and then use the page auto-refresh to get the current Upload status at every point of time, and then display them, but the efficiency of using the page auto-refresh method is relatively low, it is not difficult to adjust the refresh interval (the minimum interval is 1 second), and the server returns a large amount of data, so it cannot reflect the upload situation in real time. When the client uses javascript to call the MSXMl object and setTimout methods to regularly load an xml file, you can get server-side data without refreshing the timer. Here, you can set the progressbar. asp outputs data in xml format for the client to load, and returns only a few required parameters. In this way, the page is not refreshed, and the transmitted data is small. You do not need to upload all the data to the client, only data reflecting the status is transmitted. If the timer time is small enough, we can see the upload status in "real time. The following uses abcupload4 as an example to describe how to create a real-time file Upload progress bar. (Note: we can improve it based on the abcupload example .)
Progressupload.htm
(The front-end submission of the uploaded file. We will display the progress bar in it)
</P> <Script language = "javascript"> </P> <! -- </P>
<P> theUniqueID = (new Date ()). getTime () % 1000000000; </P> <P> function s () file: // execute the function that displays the progress bar when data is submitted </P> <P >{</P> <P>
Bar (); file: // start to execute the function that reflects the upload status </P> <P>
Document. myform. action = "progressupload. asp? ID = "+ theUniqueID;
File: // the program that processes the uploaded data </P> <P>
Document.myform.tar get = "up" file: // put the submitted data in an iframe named "up" for processing, so that the submitted page will not jump to the page for processing data.
Document. myform. submit (); file: // submit a form </P> <P>}
</P> <P> function bar () </P> <P >{</P> <P>
Bar1.style. display =; file: // Make the layer that displays the upload progress visible </P> <P>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service