file path & windows cgi

Steve Holden sholden at holdenweb.com
Thu Sep 27 15:45:34 EDT 2001


"Scott Griffitts" <scott at griffitts.com> wrote ...
> Trying to read a file, this script works for me:
>
> z = open('I:\\test\\test.txt')
> for x in z.readlines():
>     b = "%s%s" % (b,x)
> z.close()
> print b
>
> But if I try and get the path to the file via an html form:
>
> import cgi
> y = cgi.FieldStorage()
> z = open(y['getter'].value)
> for x in z.readlines():
>     b = "%s%s" % (b,x)
> z.close()
> print b
>
> I get:
>
> Traceback (most recent call last):
>   File "c:\inetpub\wwwroot\python\brow2.py", line 5, in ?
>     z = open(y['getter'].value)
> IOError: [Errno 22] Invalid argument: 'I:\\test\\test.txt'
>
> Does anyone know what I'm missing here?  Thanks.

When you run the test you are working on one environemnt, but it may be that
the same shares are not available to the web server. You don't say which web
server you are using, but certainly with IIS I've seen that shares are not
always available. I don't remeber the exact reasons, but would first of all
suggest you try accessing a file on a drive you KNOW is available (such as
C:) and then working forwards from there.

Clearly open() isn't seeing the file, and just as clearly it's reporting the
right path, so maybe its the server environment.

regards
 Steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list