Disregard my last post.

On Jul 3, 5:28 pm, Lennon <[email protected]> wrote:
> Here is the form.  I'm also using a custom uploader which is probably
> where the problem is:
>
> UPLOADER:
>
> def img_upload_widget(f,v, u):
>     inp = SQLFORM.widgets.upload.widget(f,v, u)
>     img_url = URL('default','download', args=v)
>     img = IMG(_src=img_url, _style='max-width:350px;max-height:350px')
>     return DIV(img, BR(), inp) if v else inp
>
> FORM:
>
> def edit_item():
>     is_admin()
>     print 'edit item'
>
>     for k in ('t','item_id', 'form_id'):
>         if not k in request.vars:
>             return
>         else: globals()[k] = request.vars[k]
>
>     globals()['item_id'] = int(item_id)
>
>     #get record by id
>     record = db[t](item_id)
>     if not record:return "Error: Record not found"
>
>     #create form
>     form = SQLFORM(db[t],record, _id=form_id, _class='admin-form edit-
> form')
>
>     #submit data
>     if form.accepts(request.vars, formname=None):
>         update_grid_cache(t)
>         return "success"
>     elif form.errors:
>         return form
>
> On Jul 3, 4:23 pm, Massimo Di Pierro <[email protected]>
> wrote:
>
>
>
>
>
>
>
> > You managed to bypass the web2py upload mechanism and stored a
> > FieldStorage object in the database. This is a mistake because it is
> > difficult to take it out. The problem is probably not in your model
> > but in the form you use to populate. Can you show us the action?
>
> > On Jul 3, 2:29 pm, Lennon <[email protected]> wrote:
>
> > > UPDATE:
>
> > > The error I was getting was caused by a missing ')' in the view so
> > > fixing that has gotten me to a new error.
>
> > > I simplified my model to how you have pbreit just to make things
> > > easier.
>
> > > But when I try to display the image like so:
>
> > > <img src="{{=URL('download', args=img['upload'])}}" />
>
> > > I get a 400 error in the Chrome Console:
>
> > >http://127.0.0.1:8000/sos_test/default/download/FieldStorage%28%27upl...
> > > 400 (BAD REQUEST)
>
> > > There is that field storage again.  I tried doing
> > > img['upload'].filename as recommended in this link:
>
> > >http://groups.google.com/group/web2py/browse_thread/thread/9562da3b8b...
>
> > > But I got an error that the object was a string and .fieldname
> > > wouldn't work.
>
> > > Thoughts?
>
> > > I'm using SQLForm to upload the image.  Maybe I'm doing something
> > > strange upon upload to store it in such a weird format?
>
> > > On Jul 3, 1:04 pm, pbreit <[email protected]> wrote:
>
> > > > I would suggest following the Book more 
> > > > closely:http://web2py.com/book/default/chapter/03
>
> > > > db.define_table('image',
> > > >    Field('caption'),
> > > >    Field('file', 'upload'))
>
> > > > <img src="{{=URL('download', args=image.file)}}" />

Reply via email to