Two Modes are Better than One!
   
 


$use("codex.sql")$use("codex.util")
$use("codex.http")
$use("cstdlib")

<html>
<body>

   Parts Sent:
   <ul>
      $declare(Enumeration parts = getRequest().getMIMEParts())
      $while(parts.hasNext())
         $declare(MIMEEntity curPart = <MIMEEntity>parts.next())
         <li>$(curPart.getName())
         <ul>
             <li><b>filename</b> : $(curPart.getFileName())
             <li><b>content type</b> : $(curPart.getContentType())
             <li><b>content transfer encoding</b> : $(curPart.getContentTransferEncoding())
             <li><b>body length</b> : $(curPart.getBodyLength())
         </ul>
      $endwhile
   </ul>

   <br>Uploaded File :<br>
   <img src="foo.gif">

   $if(getRequest().getMIMEPart("uploaded_file") != null &&
       getRequest().getMIMEPart("uploaded_file").getBodyLength() > 0)
      $do(
         putFileBytes(
            "/usr/local/wa/dhakim/httpd/htdocs/foo.gif",
            getRequest().getMIMEPart("uploaded_file").getBody(),
            getRequest().getMIMEPart("uploaded_file").getBodyLength()
         )
      )
   $endif

   <br>Does file /usr/local/wa/dhakim/httpd/htdocs/foo.gif exists ?
      $(existsFile("/usr/local/wa/dhakim/httpd/htdocs/foo.gif")) <br>

   <hr>
   <pre>
   '$(getValue("foo","nada"))'
   </pre>

   <table border=1><tr><td valign=top>

  Multi-Part form:<br>

   <form method=post enctype="multipart/form-data">
       File: <input type="file" name="uploaded_file" size="30" /><br>
       Text: <input type="text" name="foo" value="bar" size="30" ><br>
       <input type=checkbox name="foo" value="good">Good
       <input type=checkbox name="foo" value="bad">Bad
       <input type=checkbox name="foo" value="ugly">Ugly <br>
       <input type="submit">
   </form>

   </td><td valign=top>

   Multi-Part form W 1 upload only:<br>

   <form method=post enctype="multipart/form-data">
       File: <input type="file" name="uploaded_file" size="30" /><br>
       <input type="submit">
   </form>

   </td></tr><tr><td valign=top>

   Multi-Part form W many uploads:<br>

   <form method=post enctype="multipart/form-data">
       File 1: <input type="file" name="uploaded_file1" size="30" /><br>
       File 2: <input type="file" name="uploaded_file2" size="30" /><br>
       File 3: <input type="file" name="uploaded_file3" size="30" /><br>
       <input type="submit">
   </form>

   </td><td valign=top>

   Good Ole form W 1 upload only:<br>

   <form method=post enctype="form-data">
       File: <input type="file" name="uploaded_file" size="30" /><br>
       <input type="submit">
   </form>

   </td></tr><tr><td valign=top>

   Good Ole form :<br>
   <form method=post>
      Text: <input type="text" name="foo" value="bar"><br>
      <input type="submit">
   </form>

  </td><td valign=top>
  H Content-type : $(getRequest().getHeader("Content-type"))<br>
  H boundary 1 :  $(getRequest().getHeader("boundary"))<br>
  H boundary 2 :  $(getRequest().getHeader("     boundary"))<br>
  V boundary 1 : $(getValue("boundary")) <br>
  V boundary 2 : $(getValue("     boundary")) <br>
  </td></tr></table>

</body>
</html>