Recently, write a Django for the last file. There is no passing through.
Under the help of the great God, the end is still. But also found a problem:
Django Official website Document: https://docs.djangoproject.com/en/1.8/topics/http/file-uploads/
form definition
Class Uploadfileform (forms. Form): title = forms. Charfield (max_length=50) file = forms. Filefield ()
Form Object generation.
form = Uploadfileform (Request. POST, request. FILES)
Request. Post is in addition to request.files outside the parameters, such as title.
But the strange thing is that if I uploadfileform there's only one tile inside. This is written as form = uploadfileform (Request. FILES), you will get an error .... (I've been doing this for a long time, I don't understand, the first parameter)
This first parameter is found to be used to determine the Boolean value. Is it used for yy? Written as Uploadfileform ({},request. FILES) is no problem.
By the way to paste the method of preservation:
Def handle_upload_file (f):
"" "Save the file which is loaded" ""
Print (' in handle ')
Try
Path = Uploaded_file_dirs + time.strftime ('/%y/%m/%d/%h/%m/%s/')
Print (PATH)
if not int (os.path.exists (path)):
Os.makedirs (PATH)
Path_file_name = Path+f.name
Print (Path_file_name)
Destination = open (Path_file_name, "wb+")
For Chuck in F.chunks ():
Destination.write (Chuck)
Destination.close ()
Except Exception as E:
Print (e)
Return Path_file_name
Set enctype= "Multipart/form-data" in HTML
Django inside file Upload processing processing