Just FYI - I ended up using the models save_<fieldname>_file method like
this:

if 'avatar' in request.FILES:
     uf = request.FILES['avatar']
     os.remove(settings.MEDIA_ROOT + "/avatars/" + user.username + ".jpg")
     profile.save_profile_avatar_file("avatars/" + user.username + ".jpg",
uf)

On Wed, Jul 16, 2008 at 12:36 PM, Marty Alchin <[EMAIL PROTECTED]>
wrote:

>
> On Wed, Jul 16, 2008 at 2:50 PM, d3f3nd3r <[EMAIL PROTECTED]> wrote:
> > hello,
> > I have another problem with file upload.
> > request.FILES['file'] represents a dictionary in my view, not an object.
> >
> > Here is my code :
> >        class UserPicForm(forms.Form):
> >                userpic  = forms.FileField()
> >
> >        form = UserPicForm(request.POST,request.FILES)
> >        if form.is_valid() :
> >            handle_userpic(request.FILES['userpic'])
> >
> >        def handle_userpic(f):
> >        destination = open('/home/d3f3nd3r/hackerspace-os/mos/media/tmp',
> 'wb+')
> >        for chunk in f.chunks() : -> ERROR : 'FileDict' object has no
> attribute 'chunks'
> >                destination.write(chunk)
> >
> > I think I followed the docs at
> > http://www.djangoproject.com/documentation/upload_handling/ but it didnt
> work.
> > Any ideas ?
>
> You probably need to update to a more recent SVN checkout of Django.
> That document is only valid as of revision 7814, which went in a
> couple weeks ago.
>
> -Gul
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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