Hello, I'm trying to upload an image from a form. I'm using ImageModel with the User as a foreign key, I'm having trouble with the form . any help will be highly appreciated, please, thanks
+1
A:
Make sure your form tag contains enctype="multipart/form-data"
and that you bind your form to request.POST, request.FILES
views.py:
some_view(request):
if request.POST:
form = myForm(request.POST, request.FILES)
....
template.html:
<form method='POST' enctype='multipart/form-data'>
...
Zach
2010-01-08 16:07:24
<form method="POST" enctype="multipart/form-data"> would be better ;)
Tomasz Zielinski
2010-02-21 21:31:13
Yes I believe that would be much better, I'll fix the answer
Zach
2010-02-22 14:25:48