How to get file uploading to work in cgi?

Tyler Eaves tyler at tylereaves.com
Sun Oct 22 20:31:31 EDT 2000


Here is my code:

if formokay==1:
    thefilename=''
    theauthor=form['author'].value
    print theauthor
    for x in string.split(theauthor)[:]:
        thefilename=thefilename+string.lower(x)
    thefilename=thefilename+form['filename'].value+'.rcd'

out=open('/home/ultracoa/ultracoastercentral-www/'+thefilename,'wb')
    track=form['thetrack']
    print track
    out.write(track.file.read())
    out.flush()
    out.close()

here's the problem.
In my form I used: <INPUT TYPE="FILE">
But how come it returns the file name?

Here is a sample trace back (I have sys.stderr redirect to stdout)

test Tyler Eaves MiniFieldStorage('thetrack', 'C:\\Program
Files\\Reactor Software\\Ultra Coaster\\coasters\\darkabyss.rcd')
Traceback (innermost last): File "uccsubmit.py", line 37, in ?
out.write(track.file.read()) AttributeError: 'None' object has no
attribute 'read' 


If anyone wants to see the form, it is at
http://www.ultracoastercentral.com/cgi-bin/ucc.py?submit

Also, because I was bored, I changed my whole website to a Python CGI
:)

---
Tyler Eaves

Visit Ultra Coaster Central!
The internet's largest repository
of Ultra Coaster Tracks!

http://www.ultracoastercentral.com


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----



More information about the Python-list mailing list