Ajax Implementation Upload progress bar (Django)

Source: Internet
Author: User
Tags button type file upload progress bar

Yesterday studied a day file upload progress bar implementation, toss a day is finally completed, during the encounter a variety of bugs, people can not help but tears fall.

Here, we will use the smallest amount of Ajax to implement this feature, without any browser-support detection, so it is easier to understand. Another point to note is that the background should also be involved in a foot (with), of course, very simple, as long as the confirmation of the acceptance of the file on the line (later will be explained). I'm using the Django framework to do the backstage.

There is not much to say, first on the code, the code will give a detailed explanation. First give the front end:

<!
	DOCTYPE html> 

Urls.py has the following 2 pattern matches
URL (r ' ^upload_page/$ ', upload_page)
url (r ' ^upload/$ ', upload)
Views.py has the following 2 request processing functions
def upload_page (Request): Return
    render (request, ' upload_page.html ')   #这里upload_ Page is the top-end HTML file
def upload (request):
    file = Request. FILES   #一定要调用上传的文件 (no matter what you do, save or do nothing, anyway, do not call on the error, it is estimated that the default does not call do not receive it. Can upload success with Ajax, or error, reason unknown return
    HttpResponse ()

Related Article

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.