file path & windows cgi

Scott Griffitts scott at griffitts.com
Thu Sep 27 14:19:49 EDT 2001


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.



More information about the Python-list mailing list