Well, I'm really not sure what you've got going on. You definitely
need enctype="multipart/form-data" for it to work. Have you tried
saving a file in the default admin for the model? If so, does it work
as expected? If not, maybe you have MEDIA_ROOT set wrong. Also try
simplifying your form to make sure there's nothing wrong there. Try:
<form enctype="multipart/form-data" method="post" action=".">
{{ form }}
</form>
I'm really not coming up with anything else, but maybe you could post
more of your code for the view and the template.
On Jun 3, 3:30 pm, cesco <[EMAIL PROTECTED]> wrote:
> On Jun 3, 6:52 pm, sansmojo <[EMAIL PROTECTED]> wrote:
>
> > The raw, binary data of the file. After uploading, it ends up at
> > request.FILES['file']['content'] (where 'file' is the name of your
> > form field).
>
> > An example:
>
> > if request.FILES.has_key('file'):
> > new_file = File(some_field='some_val',
> > date_uploaded=datetime.now())
> > new_file.save_file_file(request.FILES['file']['filename'],
> > request.FILES['file']['content']) # because the field name is file
> > new_file.save
>
> Thanks for the reply but I still can't get it to work.
> In the form.py I have the following code:
>
> class AddOfferForm(forms.Form):
> picture = forms.CharField(widget=forms.FileInput())
> ...
>
> and in the template I have:
>
> <form method="post" action="./">
> <p>
> {{ form.picture }}
> </p>
> </form>
>
> and in the view.py I do
> print request.FILES
> but it's always empty (unlike request.POST which gives the expected
> values).
>
> I tried also to include the following in the form:
> enctype="multipart/form-data"
> and to have {{ form.picture_file }} beside {{ form.picture }} as
> pointed out here:http://www.djangoproject.com/documentation/forms/
> but the request.FILES was still empty.
>
> Do you have any idea on what's wrong?
>
> Any help would be very appreciated.
>
> Thanks and regards
> Francesco
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---