/ app / upload“'file'”

时间:2017-11-08 04:45:15

标签: python

/ app / upload“'file'的MultiValueDictKeyError”错误发生。

我写了

import os
import shutil
def upload(request):
    file = request.FILES['file'].temporary_file_path()

  with open(file, 'rb') as f:
         file_content = f.read()

  with open("test.wav", 'wb') as f:
       f.write(file_content)
       f.close() 
       shutil.move("test.wav", "/Users/xxx/Downloads/test.wav")

我设置了密钥文件&对POSTMAN中的wav文件赋值 enter image description here

我运行此代码,错误发生。我不知道为什么会发生此错误,因为我认为当我以错误的方式使用html时会发生此错误<form action="" method="post">

在这种情况下,enctype="multipart/form-data"不存在,所以发生MultiValueDictKeyError。但是现在我通过POSTMAN发送数据,所以我真的不明白为什么会发生这个错误。我该如何解决这个问题?

0 个答案:

没有答案
相关问题