Here's my get and post methods and well as the attached test data:

class index:
    def GET(self):
    web.header("Content-Type","text/html; charset=utf-8")
    return render.index(form)
    def POST(self):
        x = web.input(calendar_file={}, ref_id='')
        if x:
            ref_id = (x.ref_id if x.ref_id else "")
            filepath=x.calendar_file.filename # replaces the windows-style
slashes with linux ones.
            fn=filepath.split('/')[-1] # splits the and chooses the last
part (the filename
            filename =
"%s/Users/jl98567/Documents/xMatters_calendar_app/test/" + fn
            fullpath = os.path.join('c:', filename % (ref_id))
            content = x["calendar_file"].file.read()
            with open(fullpath, 'w') as f_out:
                if not f_out:
                    raise Exception("Unable to open %s for writing. " %
(fullpath))
                f_out.write(content)

        print x['calendar_file'].value

        raise web.seeother('/upload?ref_id=%s&filename=%s' % (ref_id,
filename))

Thank you so much!

On Mon, Jan 20, 2014 at 5:52 PM, Hugo Lol <[email protected]> wrote:

> Can you upload the Excel file or something so I can test this in my PC?
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "web.py" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/webpy/_i64Ym_Ubxg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/webpy.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/groups/opt_out.

Attachment: testdata.xls
Description: MS-Excel spreadsheet

Reply via email to