The Django Framework form form and Ajax upload file

Source: Internet
Author: User

Browse Catalogs
    • Form form upload File

    • Ajax Uploading Files

    • Forge Ajax Upload Files

Form form upload file html

Note: You must add the Enctype= "Multipart/form-data property.

View
def index (Request):    return render (Request, "index.html") def upload_file (request):    print ("FILES:", request.) FILES)    print ("POST:", request.) POST)    return HttpResponse ("Upload succeeded!")
Ajax uploading files What is Formdata

XMLHttpRequest Level 2 Adds a new interface FormData . Using FormData对象 JavaScript, we can simulate a series of form controls with some key-value pairs, and we can also use the send() XMLHttpRequest method to submit the "form" asynchronously. The FormData biggest advantage of using it is that we can upload a binary file asynchronously, rather than the usual Ajax.

This object has been supported by newer versions of all major browsers, such as Chrome 7+, Firefox 4+, IE + +, Opera 12+, Safari 5+. Html
Note: Contenttype:false, Processdata:false, essential. views.py
def index (Request):      return render (Request, "index.html")    def upload_file (request):    print ("FILES:", Request. FILES)    print ("POST:", request.) POST)    return HttpResponse ("Upload succeeded!")
Forge Ajax Upload File iframe tags

<iframe> tags provide an inline framework.

An inline frame is used to embed another document in the current HTML document.

Example:

<iframe src= "http://www.baidu.com" width= "1000px" height= "600px" ></iframe>  
Iframe+form
  
Views
def index (Request):     return render (Request, "index.html") def upload_file (request):    print ("FILES:", request.) FILES)    print ("POST:", request.) POST)    return HttpResponse ("Upload succeeded!")

  

The Django Framework form form and Ajax upload file

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.