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.
Viewdef 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 FormdataXMLHttpRequest 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+. HtmlNote: Contenttype:false, Processdata:false, essential. views.pydef 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
Viewsdef 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