Ajax Upload file progress bar display

Source: Internet
Author: User

To achieve the display of the progress bar, you need to know two parameters, the size of the upload and the total file size HTML5 provides an upload process event, triggered during the upload process, and then use the uploaded size/total size, calculate the percentage of uploads, and then use this percentage to control the display of the Div box, You can implement the upload progress bar effect


Front Page

<!doctype html>loaded:15020, total:15020, eventphase:0, Bubbles:false, Cancelable:false, Defaultprevented:false,
timestamp:1445144855459000, Originaltarget:xmlhttprequestupload}if (ev.lengthcomputable) {var precent=100 * Ev.loaded/ev.total;console.log (precent);d Ocument.getelementbyid (' nei '). style.width=precent+ '% '; document.getElementById (' precent '). Innerhtml=math.floor (precent) + '% ';}} Fd.append (' pic ', pic); Xhr.send (FD);} </script><style> #wai {width:500px;height:30px;border:1px solid green;} #nei {width:0px;height:30px;background:green;} </style>

Page Display effect

Ajax Upload file progress bar display

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.