昨天有同学问我,这个问题怎么解决。
DebugFilesKeyError:
You tried to access the file "file" in the request.
"application/x-www-form-urlencoded"
instead of "multipart/form-data" which means
To fix this error you should provide enctype="multipart/form-data" in your form.
The browser instead transmitted some file names.
This was submitted: "xxxx"
上面这个问题主要是在前端出现的错误,
python中不管是Django框架或Flask框架,
或者其他语言都会有类似的错误,
其实错误提醒上就已经给出了答案。
原因是:因post(上传)的是一个文件,
而并没有给form表单添加相应的属性,
这样可以解决:
在你的前端页面form表单中添加上,
enctype=“multipart/form-data”
像这样:
欢迎大家阅读我的文章。
欢迎进(Q)群,帮你解决问题: