[Tutor] uploading files, the latest and final migrain source
Kirk Bailey
idiot1 at netzero.net
Tue Aug 26 20:22:46 EDT 2003
ok, still trying to crack the last tough nut- all the rest of the wiki is ready.
Uploading with a http form/post method.
here's a form"
http://www.tinylist.org/testform/html
it is reproduced on the footer of the wiki'e editor page. TO access it, go here
http://www.tinylist.org/cgi-bin/wikinehesa.py/SandBox
which brings up the sandbox, a playpen page, don't worry about the possibility
of altering or even emptying it, that's what the sandbox is there for- it's the
scratchmonkey. Click EDIT THIS PAGE in the footer. Up comes the editor. Look at
the footer. Nice features here, but right now let's look at the middle at the
upload image file utility. The form part works fine. It feeds to a script, which
is like this at the moment:
#!/usr/local/bin/python
#
import os, cgi, sys # swallow the batteries...
#
footer='<P><br>That\'s all, folks.<P></body></html>' # define the webpage
footer for later use.
form = cgi.FieldStorage() # extract the datapackage into a dictionary 'form',
data=form['userfile'].value
# filedata=form.getvalue('userfile','')
print 'Content-type:text/html\n' # warn apache what's coming down the pipe,
print '<html><head>' # open the webpage up,
print "<title>Upload results</title></head>" # name it,
print '<body bgcolor="FFFFFF" links="0000FF"><P>' # set up the bage body,
print '<center><h2>RESULTS</h2></center><P>' # generate a descriptive header
print 'form=',form,'<P>That\'s the entire thing recovered from the
cgi.FieldStorage() object.<P>'
print 'the form has these keys:',form.keys(),'<P>'
print 'we assign to "data" the value form[\'userfile\'].value and get:<br>'
print 'data has this in it:',data,'<P>'
print footer
sys.exit()
There's more after that, but it never runs, and never will until I get this part
cracked. This is the sort of stuff you get to see on your browser as a result of
it running:
form= FieldStorage(None, None, [FieldStorage('userfile', 'wikinehesalogo3.png',
'\211PNG\015\012\032\012\000\000\000\015IHDR\000\000\001;\000\000\000.\0(etc...)
and further on:
That's the entire thing recovered from the cgi.FieldStorage() object.
the form has these keys: ['userfile']
we assign to "data" the value form['userfile'].value and get:
data has this in it: ‰PNG (etc...)
it's a lot, but not in anything I can manipulate, or use. TAKE A LOOK. it will
abort before writing anything to my server. See if you have a clue you can spare me.
--
--
end
Cheers!
Kirk D Bailey
+ think +
http://www.howlermonkey.net +-----+ http://www.tinylist.org
http://www.listville.net | BOX | http://www.sacredelectron.org
Thou art free"-ERIS +-----+ 'Got a light?'-Promethieus
+ think +
Fnord.
More information about the Tutor
mailing list