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 django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to