[英]dead simple Django file uploading not working :-((
I am trying desperately to do a very simple file upload with Django, without (for now) bothering with templating & co. 我正在拼命地尝试用Django做一个非常简单的文件上传,而没有(暂时)困扰着模板&co。
My HTML is: 我的HTML是:
<form
id="uploader"
action="bytes/"
enctype="multipart/form-data"
method="post"
>
<input type="file" name="uploaded"/>
<input type="submit" value="upload"/>
</form>
My Python is (knowing it is a POST): 我的Python是(知道它是POST):
if path=="bytes/":
if 'uploaded' in request.FILES:
return HttpResponse("you uploaded a file")
else:
return HttpResponse("did not get the file")
I don't understand why I'm always getting the "did not get the file" message... 我不明白为什么我总是收到“未获取文件”消息...
Can anyone help me, please??? 谁能帮我吗?
Try changing " if 'uploaded' in request.FILES:
" to " if request.FILES
". 尝试将
if 'uploaded' in request.FILES:
“ if 'uploaded' in request.FILES:
更改为“ if request.FILES
”。
You might want to take a look at the documentation as well; 您可能还需要看一下文档。 there's an example-- http://docs.djangoproject.com/en/dev/topics/http/file-uploads/
有一个例子-http: //docs.djangoproject.com/en/dev/topics/http/file-uploads/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.