librelist archives

« back to archive

Hi.. problem with flask wtf (FileField)

Hi.. problem with flask wtf (FileField)

From:
alice ni
Date:
2010-10-30 @ 04:06
Hi, I have a form class which looks like the below:-
>
> class UserCreateForm(wtf.Form):
>
>      name=wtf.TextField('Name')
>
>      email=wtf.TextField('Email')
>
>      country=wtf.TextField('Country')
>
>      image=wtf.FileField(u'Upload Image')
>
> Now after the form is submitted , I am trying to get the file using

> file=request.files['image']



but it does not work . I even tried

> filename=form.image.file.filename

but it says FileField does not have an attribute file

Can someone please point me out to where I might be going wrong!

>

Re: Hi.. problem with flask wtf (FileField)

From:
alice ni
Date:
2010-10-30 @ 05:08
I solved it.. was an error on my part!

On Sat, Oct 30, 2010 at 9:36 AM, alice ni <alice.ni19@gmail.com> wrote:

> Hi, I have a form class which looks like the below:-
>>
>>  class UserCreateForm(wtf.Form):
>>
>>      name=wtf.TextField('Name')
>>
>>      email=wtf.TextField('Email')
>>
>>      country=wtf.TextField('Country')
>>
>>      image=wtf.FileField(u'Upload Image')
>>
>> Now after the form is submitted , I am trying to get the file using
>
>> file=request.files['image']
>
>
>
> but it does not work . I even tried
>
>> filename=form.image.file.filename
>
> but it says FileField does not have an attribute file
>
> Can someone please point me out to where I might be going wrong!
>
>>
>
>

Re: [flask] Re: Hi.. problem with flask wtf (FileField)

From:
Thadeus Burgess
Date:
2010-10-30 @ 06:40
Care to share solution? Just for completeness sake.

--
Thadeus




On Sat, Oct 30, 2010 at 12:08 AM, alice ni <alice.ni19@gmail.com> wrote:

> I solved it.. was an error on my part!
>
>
> On Sat, Oct 30, 2010 at 9:36 AM, alice ni <alice.ni19@gmail.com> wrote:
>
>> Hi, I have a form class which looks like the below:-
>>>
>>>  class UserCreateForm(wtf.Form):
>>>
>>>      name=wtf.TextField('Name')
>>>
>>>      email=wtf.TextField('Email')
>>>
>>>      country=wtf.TextField('Country')
>>>
>>>      image=wtf.FileField(u'Upload Image')
>>>
>>> Now after the form is submitted , I am trying to get the file using
>>
>>> file=request.files['image']
>>
>>
>>
>> but it does not work . I even tried
>>
>>> filename=form.image.file.filename
>>
>> but it says FileField does not have an attribute file
>>
>> Can someone please point me out to where I might be going wrong!
>>
>>>
>>
>>
>

Re: [flask] Re: Hi.. problem with flask wtf (FileField)

From:
alice ni
Date:
2010-10-30 @ 09:49
Well.. missed out enctype in the form! .. :-)

On Sat, Oct 30, 2010 at 12:10 PM, Thadeus Burgess <thadeusb@thadeusb.com>wrote:

> Care to share solution? Just for completeness sake.
>
> --
> Thadeus
>
>
>
>
>
> On Sat, Oct 30, 2010 at 12:08 AM, alice ni <alice.ni19@gmail.com> wrote:
>
>> I solved it.. was an error on my part!
>>
>>
>> On Sat, Oct 30, 2010 at 9:36 AM, alice ni <alice.ni19@gmail.com> wrote:
>>
>>> Hi, I have a form class which looks like the below:-
>>>>
>>>>  class UserCreateForm(wtf.Form):
>>>>
>>>>      name=wtf.TextField('Name')
>>>>
>>>>      email=wtf.TextField('Email')
>>>>
>>>>      country=wtf.TextField('Country')
>>>>
>>>>      image=wtf.FileField(u'Upload Image')
>>>>
>>>> Now after the form is submitted , I am trying to get the file using
>>>
>>>> file=request.files['image']
>>>
>>>
>>>
>>> but it does not work . I even tried
>>>
>>>> filename=form.image.file.filename
>>>
>>> but it says FileField does not have an attribute file
>>>
>>> Can someone please point me out to where I might be going wrong!
>>>
>>>>
>>>
>>>
>>
>

Re: [flask] Re: Hi.. problem with flask wtf (FileField)

From:
danjac354@gmail.com
Date:
2010-11-01 @ 11:47
I'm considering adding file-based validators as well - for example,
the required validator doesn't work on file fields, as the
request.form field is empty, even if the request.files field is not.

This might be used with Flask-Uploads so it's possible to check
specific file types such as images as well.

On 30 October 2010 10:49, alice ni <alice.ni19@gmail.com> wrote:
> Well.. missed out enctype in the form! .. :-)
>
> On Sat, Oct 30, 2010 at 12:10 PM, Thadeus Burgess <thadeusb@thadeusb.com>
> wrote:
>>
>> Care to share solution? Just for completeness sake.
>>
>> --
>> Thadeus
>>
>>
>>
>>
>> On Sat, Oct 30, 2010 at 12:08 AM, alice ni <alice.ni19@gmail.com> wrote:
>>>
>>> I solved it.. was an error on my part!
>>>
>>> On Sat, Oct 30, 2010 at 9:36 AM, alice ni <alice.ni19@gmail.com> wrote:
>>>>
>>>> Hi, I have a form class which looks like the below:-
>>>>>>
>>>>>> class UserCreateForm(wtf.Form):
>>>>>>
>>>>>>      name=wtf.TextField('Name')
>>>>>>
>>>>>>      email=wtf.TextField('Email')
>>>>>>
>>>>>>      country=wtf.TextField('Country')
>>>>>>
>>>>>>      image=wtf.FileField(u'Upload Image')
>>>>
>>>> Now after the form is submitted , I am trying to get the file using
>>>>>
>>>>> file=request.files['image']
>>>>>
>>>>>
>>>>
>>>> but it does not work . I even tried
>>>>>
>>>>> filename=form.image.file.filename
>>>>
>>>> but it says FileField does not have an attribute file
>>>> Can someone please point me out to where I might be going wrong!
>>>>>
>>>>>
>>
>
>

Re: [flask] Re: Hi.. problem with flask wtf (FileField)

From:
alice ni
Date:
2010-11-01 @ 12:55
Hi danjac ! I have done something like that ..You can read the mail
concerning this at the below link for that:-

http://groups.google.com/group/wtforms/browse_thread/thread/bb42b8c1763c5141


On Mon, Nov 1, 2010 at 5:17 PM, danjac354@gmail.com <danjac354@gmail.com>wrote:

> I'm considering adding file-based validators as well - for example,
> the required validator doesn't work on file fields, as the
> request.form field is empty, even if the request.files field is not.
>
> This might be used with Flask-Uploads so it's possible to check
> specific file types such as images as well.
>
> On 30 October 2010 10:49, alice ni <alice.ni19@gmail.com> wrote:
> > Well.. missed out enctype in the form! .. :-)
> >
> > On Sat, Oct 30, 2010 at 12:10 PM, Thadeus Burgess <thadeusb@thadeusb.com
> >
> > wrote:
> >>
> >> Care to share solution? Just for completeness sake.
> >>
> >> --
> >> Thadeus
> >>
> >>
> >>
> >>
> >> On Sat, Oct 30, 2010 at 12:08 AM, alice ni <alice.ni19@gmail.com>
> wrote:
> >>>
> >>> I solved it.. was an error on my part!
> >>>
> >>> On Sat, Oct 30, 2010 at 9:36 AM, alice ni <alice.ni19@gmail.com>
> wrote:
> >>>>
> >>>> Hi, I have a form class which looks like the below:-
> >>>>>>
> >>>>>> class UserCreateForm(wtf.Form):
> >>>>>>
> >>>>>>      name=wtf.TextField('Name')
> >>>>>>
> >>>>>>      email=wtf.TextField('Email')
> >>>>>>
> >>>>>>      country=wtf.TextField('Country')
> >>>>>>
> >>>>>>      image=wtf.FileField(u'Upload Image')
> >>>>
> >>>> Now after the form is submitted , I am trying to get the file using
> >>>>>
> >>>>> file=request.files['image']
> >>>>>
> >>>>>
> >>>>
> >>>> but it does not work . I even tried
> >>>>>
> >>>>> filename=form.image.file.filename
> >>>>
> >>>> but it says FileField does not have an attribute file
> >>>> Can someone please point me out to where I might be going wrong!
> >>>>>
> >>>>>
> >>
> >
> >
>