action in the form of a request to control where to submit
method request method if the default is not written request to get
If you want to transfer files must be changed to make the default urlencoded enctype = "multipart / form-date"
The back-end code
def upload_file(request): if request.method == 'POST': print('path:',request.path) print('full_path:',request.get_full_path()) # print(request.FILES) file_obj = request.FILES.get('my_file') print(file_obj.name) with open(file_obj.name,'wb') as f: for line in file_obj.chunks(): f.write(line) return HttpResponse('OK') return render(request,'index.html')
Front and rear ends the transmission data encoding format contentType
urlencoded
A data format: name = jason & password = 666
Back-end data acquisition: rrequest.POST
formdat to
Encoding format file transfer sheet form
Back-end data acquisition file formats: request.FILES
Back-end data acquisition ordinary key-value pairs: request.POST