[Zope] Register

Kotien Wu wuko@mail.nih.gov
Mon, 24 Sep 2001 11:56:12 -0400


if we have form 
<form name="pform" enctype="multipart/form-data" 
action="url/GetUgClones" method=POST>
<input type=file name="filename">
<input type=submit value="Create Clone List">
</form>
and we can get this file from dtml GetUgClones which can call a py function to process the file.

My question is if there a way to print out or display
whole real thing which is uploaded from client.

like 

POST ...
Content-Type: ...
Content-Length: 222

----------------------------12345678
Content-Disposition: form-data; name="file"; filename="filename"

file body

----------------------------12345678--

My real question is how to upload a file which is not
at hard drive, it is in the memory.

I know how POST text data to server using python:
import httplib, urllib 
body = urllib.urlencode({'spam':1,'eggs':2,'bacon':0})

  h = httplib.HTTP("url")
  h.putrequest("POST", "http://url/CGAP/Reagents/UploadFile")
  h.putheader("Content-type", "application/x-www-form-urlencoded")
  h.putheader("Content-length", "%d" % len(body))
  h.putheader('Accept', 'text/plain')
  h.putheader('Host', 'url')
  h.endheaders()
  h.send(body) 
  reply, msg, hdrs = h.getreply()
  print reply 
  data = h.getfile().read() # get the raw HTML
  print data


but I don't know how to POST a file to Zope.
I did it at other server before.

Thanks!

Kotien Wu