I dont have much programming exp in python and web2py.
I am creating a project where you create a a database of say jigsaw
puzzles. Is there any way to preview the image of a uploaded database
field before you would submit and process the input form


I would like the add form, to display the preview of the image before
being added to the database
my code so far
db.py file

db=SQLDB("sqlite://jigsaw.db")

db.define_table('size',
    SQLField('pices'))


db.define_table('jigsaw',
    SQLField('Company_Brand'),
    SQLField('Series_Name'),
    SQLField('Name_of_Puzzle'),
    SQLField('Size_of_Puzzle',db.size),
    SQLField('Non_Standard_No_of_Piecs'),
    SQLField('picture','upload'))

db.jigsaw.Company_Brand.requires=[IS_NOT_EMPTY()]
db.jigsaw.Series_Name.requires=[IS_NOT_EMPTY()]
db.jigsaw.Name_of_Puzzle.requires=[IS_NOT_EMPTY()]
db.size.pices.requires = IS_NOT_IN_DB(db,'size.pices')
db.jigsaw.Size_of_Puzzle.requires = IS_IN_DB(db,'size.id','%(pices)s')


controller

def index():
    return dict() ###

def download(): ###
    return response.download(request,db) ###

def add():
    form=SQLFORM(db.jigsaw)
    if form.accepts(request.vars, session):
                redirect(URL(r=request, c='default', f='index'))
    records=db(db.jigsaw.id>3).select()
    return dict(form = form,records =
records,upload=URL(r=request,f='download')) ###

views are standard

Reply via email to