oh ! I could did it.

As I suspected, my "image=form.vars['test']" was not correct.
Here is the solution :
db.image.insert(name='test',
image=db.image.store(form.vars['test'].file))


On Nov 9, 9:57 am, Alex <[email protected]> wrote:
> I'm creating a field and add it to the form like this :
>
> form = SQLFORM(db.image)
> my_extra_element = TR(LABEL('test') ,INPUT(_name='test',_type='file'))
> form[0].insert(-1,my_extra_element)
>
> if form.process().accepted:
>         db.image.insert(name='test', image=form.vars['test'])
>
> Maybe my "image=form.vars['test']" is not correct ?
>
> On Nov 8, 9:46 pm, Anthony <[email protected]> wrote:
>
> > It looks like you have attempted to directly store the cgi.FieldStorage
> > object in the db field, which won't work. Please show the code used to get
> > the file uploaded.
>
> > On Tuesday, November 8, 2011 6:16:11 AM UTC-5, Alex wrote:
>
> > > I don't know why, but when I upload an image, the uploads folder is
> > > empty !
>
> > > In my table I can see  :
> > > FieldStorage('800x480', 'a800x480.jpg', '\xff\x ..... xe0\x00')
>
> > > In my view I'm doing this :
> > > <img src="{{=URL('download', args=myTable.image)}}" />
> > > {{=myTable.name}}
>
> > > I can see the name of my image, but no image (that makes sense because
> > > my uploads folder is empty....)
>
> > > I'm on Linux, I did "chmod 777 uploads", but still same pb
>
> > > Is there a configuration that I forgot to do ?
>
> > > db.define_table('image',
> > >   Field('name', length=45),
> > >   Field('image', 'upload'),
> > > )

Reply via email to