I'm still confused about the uploadfolder.

Why do I need to specify it when using SQLFORM.factory but not when using SQLFORM.smartgrid over a table with an 'upload' field.

Why doesn't it use the default /uploads folder?

Where does the default get set?

I'm following the example as in the book on page 342. I'm running trunk, updated this morning at 8:20 central.

    -Jim

On 1/2/2012 5:18 PM, Alan Etkin wrote:
Uploadfolder sets a custom folder instead of app/uploads. The function
parameters are available at API docs:

http://web2py.com/examples/static/epydoc/web2py.gluon.dal.Field-class.html

On 2 ene, 18:34, Jim Steil<[email protected]>  wrote:
found the solution.

in the code below, change line

importfile = request.vars.importFile.file

to

importfile = request.vars.importFile.value

Still don't know why I need the uploadfolder, but this solved my main issue.

      -Jim

On 1/2/2012 12:39 PM, Jim Steil wrote:

Hi
I have an upload field defined in a SQLFORM.factory form as follows:
def wasptime():
     from reports.payroll import wasptime
     response.title = 'WASPTime Payroll Import Conversion'
     form = SQLFORM.factory(
             Field('importFile', 'upload', label='WASPTime File',
                   uploadfolder='c:/deleteme/payroll/test'),
             Field('processDate', 'date', required=True,
                   requires=IS_DATE('%m/%d/%Y'),
                   label='Process Date'))
     if form.process().accepted:
         importFile = request.vars.importFile.file
         processDate = request.vars.processDate
         wasptime.payrollImport(processDate, importFile, 'testfile.csv')
     return dict(form=form)
in my wasptime.payrollImport method I am trying to read through the
lines in the uploaded file using:
def payrollImport(dateWorked, f, outputFile):
     for line in f.readlines():
         ...processing takes place here for each line in the file
but, I'm not getting any lines to print.  Can't seem to find the right
way to handle this.
In addition, why do I need to specify an uploadfolder in the 'upload'
field definition in SQLFORM.factory?
Thanks
     -Jim

Reply via email to