Here is a model table for holding picture names:

db.define_table('mypictures', 
    Field('description', 'string'),
    Field('mypicture', 'upload'))

If I try to upload a picture through simple SQLFORM everything works ok, 
picture is renamed to something like 
'mypictures.mypicture.be0ff92956b815ab.70756c6933312e6a7067.jpg' and I can 
show it in view. 

def SendPicture():   
    form=SQLFORM(db.mypictures)
    
    if form.accepts(request, session):
        response.flash = "picture uploaded"
    
    return dict(form=form)
This is the created html and everything works ok, I can show it or download 
it:
<img src=
"/showpics/default/download/mypictures.mypicture.be0ff92956b815ab.70756c6933312e6a7067.jpg"
 
width="300" />


However if I try to upload a picture through SQLFORM.factory and then 
insert values into database and then if I try to show it or download it 
web2py responds with "400 not found" although picture is uploaded. 

def SendPicture():   
    form = SQLFORM.factory(
        Field('description', 'string'),
        Field('mypicture', 'upload', uploadfolder=os.path.join(request.
folder, 'uploads/')))
    
    if form.accepts(request, session):
        response.flash = "picture uploaded"
        db.mypictures.insert(description=form.vars.description, mypicture=
form.vars.mypicture)

    return dict(form=form)

This is the html code created, picture is not shown and if I try to 
download it, I get a '400 not found' response although the picture exists 
on a given location.

<img src=
"/showpics/default/download/no_table.mypicture.80201cf3260698b3.70756c695f73615f6a657a696b6f6d322e6a7067.jpg"
 
width="300" />




-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to