Saturday, November 22, 2014

Re: Image input missing from POST request

On Friday, November 21, 2014 7:56:54 PM UTC-8, Abhishek Batra wrote:
Hi,

This is probably not a Django issue, but just trying my luck.

I have an input field corresponding to a Django ImageField in a Django template. Rendered, the HTML looks like:

<form action="/accounts/username/"         method="post"         id="profile_form"        enctype="multipart/form-data">  </form>  ... (other input fields and elements)  <input form="profile_form" id="id_profile_pic" name="profile_pic" type="file" />

The corresponding View is an UpdateView. I found request.FILES to be empty and request.cleaned_data to contain 'profile_pic': None.

I used firebug to track the POST data. It contained other fields but not profile_pic.

Can anyone say why the file does not get uploaded? I've posted this question to StakOverflow as well, in case someone wants reputation points.

Thanks,
Abhishek Batra



The input field is outside the closing </form> tag so would not be uploaded as part of the form. 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a9f69f16-861c-4a47-bd7f-6c52576ed739%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment