[英]request.FILES empty uploading image on Django
Here is my HTML sending the request, printing request.FILES
return <MultiValueDict: {}>
. 这是我的HTML发送请求,打印
request.FILES
返回<MultiValueDict: {}>
。 Also i would ask how can i save my charged picture (is ok to only form.save()
?) 另外我会问我如何保存我带电的图片(只可以
form.save()
吗?)
<form action="send_news" method="POST" encrypt="multipart/form-data">
{% csrf_token %} {{ form.as_p }}
<p>
<label for="news_title">Your name: </label>
<input id="news_title" type="text" name="news_title" value="newtitle">
</p>
<p>
<label for="news_small_description">Your name: </label>
<input name="news_small_description" id="news_small_description" value="news_small_description">
</p>
<p>
<label for="news_description">Your name: </label>
<input name="news_description" id="news_description" value="news_description">
</p>
<p>
<label for="news_image">Your name: </label>
<input id="news_image" type="file" class="" name="news_image">
</p>
<input type="submit" value="Submit" />
</form>
printing request.FILES return <MultiValueDict: {}>
. 打印request.FILES返回
<MultiValueDict: {}>
。 Also i would ask how can i save my charged picture (is ok to only form.save()
?) 另外我会问我如何保存我带电的图片(只可以
form.save()
吗?)
The problem is you are using encrypt
but you need to use enctype
问题是您正在使用
encrypt
但需要使用enctype
eg 例如
<form action="send_news" method="POST" enctype="multipart/form-data">
See What does enctype='multipart/form-data' mean? 请参阅enctype ='multipart / form-data'是什么意思? for more info if needed.
有关更多信息(如果需要)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.