Spyce => was {Re: [Edu-sig] java vs. python....}

Jason Cunliffe Jason Cunliffe" <jasonic@nomadics.org
Sat, 7 Sep 2002 13:48:16 -0400


I have recently been exploring the wonders of file upload via HTTP using
enctype="multipart/form-data". Spyce has the *sweetest* solution yet:


-- "fileupload.spy"--

[[\
if request.post('ct'):
  response.setContentType(request.post1('ct'))
  response.write(request.file('upfile').value)
  raise spyce.spyceDone
]]
<html><body>
  Upload a file and it will be sent back to you.<br>
  [[-- input forms --]]
  <hr>
  <table>
    <form action="[[=request.uri('path')]]" method=post
        enctype="multipart/form-data">
      <tr>
        <td>file:</td>
        <td><input type=file name=upfile></td>
      </tr><tr>
        <td>content-type:</td>
        <td><input type=text name=ct value="text/html"></td>
      </tr><tr>
        <td><input type=submit value=ok></td>
      </tr>
    </form>
  </table>
</body></html>


That's all folks!
./Jason