On Jul 1, 8:36 am, Tom Chang <[email protected]> wrote:
> web2py experts,
>
> a newbie here trying to learn web2py on my first app.
>
> Basically, I want a user to upload a text file (work perfectly right
> from web2py). Then, the backend (controller) will analyze the text
> files, and then display the output back to the user.
>
> The problem I ran into is after I retrive the new filename
> information, I need to have the controller to open up the text file
> and then analyze it. I ran into the following exception:
>
>     f = open(myFile,'r').read()
> IOError: [Errno 2] No such file or directory: ''
>
> The file path is:
> /applications/IOS_Audit/uploads/config.file.924bea965800dbdf.
> 736172697373612e6a73.js
>
> So wondering my path is wrong probably? any suggestion on the right
> path to use?

It looks like you are using the <fieldname>_newfilename for this, but
just to be sure, see 
http://web2py.com/book/default/section/7/2?search=newfilename

The next thing clear is your path:   It is relative to your web2py
installation (notice it _begins_ with applications).

Try joining this with request.env.web2py_path  (you can peruse
request, among other places, here: 
http://web2py.com/examples/simple_examples/hello6,
and in the same application / example in your own development copy).
The generic view in views/generic.html has the code for showing the
request, so you can simply craft up an example controller for yourself
without a corresponding default view, and the generic one will be
used.

Hope this helps.

Regards,
- Yarko

>
> best regards,
> TC

Reply via email to