<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div>Hello</div><div><br></div><div>I am turning a small web application using web/server into a cgi script</div><div>so far so good, but I got stuck when I tried rewriting my file upload function</div><div><br></div><div>the form to upload an image was:</div><div><br></div><div>(form ((action ,(make-url add-image))</div><div> (method "post")</div><div> (enctype "multipart/form-data"))</div><div> (input ((type "file")(name "image")))</div><div> (input ((type "submit"))))</div><div><br></div><div><br></div><div>and the form handler was:</div><div><br></div><div>(define (add-image request)</div><div><div> (match</div><div> (bindings-assq #"image" (request-bindings/raw request))</div><div> [(? binding:file? b)</div><div> (let ([filename (bytes->string/utf-8 (binding:file-filename b))])</div><div> (save-image! (binding:file-content b) filename images-path)</div><div> (portfolio-insert-image! a-portfolio filename))</div><div> ])</div><div> (admin (redirect/get)))</div><div><br></div><div>this worked fine.</div><div>I got the filename with: (binding:file-filename b)</div><div>and the file content with: (binding:file-content b)</div><div><br></div><div>Now I am trying to write the same function using what is provided by net/cgi, namely :</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#863C22" face="Courier" size="3"><span class="Apple-style-span" style="font-size: 13px;"><table cellspacing="0" cellpadding="0" style="padding: 2.0px 0.0px 2.0px 0.0px"> <tbody> <tr> <td valign="middle" style="width: 559.0px; padding: 0.0px 1.0px 0.0px 1.0px"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font size="4" style="font: normal normal normal 13px/normal Courier; "><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial">(</font></font><a href="http://docs.plt-scheme.org/net/cgi.html#(def._((lib._net/cgi..ss)._get-bindings))"><font style=""><font class="Apple-style-span" color="#000000"><span class="Apple-style-span" style="text-decoration: none;"><font class="Apple-style-span" face="Arial">get-bindings</font></span></font></font></a><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial">) </font></font></font></div></td></tr> </tbody> </table></span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#863C22" face="Courier" size="3"><span class="Apple-style-span" style="font-size: 13px;"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font size="4" style="font: normal normal normal 13px/normal Courier; "><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial">(</font></font><a href="http://docs.plt-scheme.org/net/cgi.html#(def._((lib._net/cgi..ss)._extract-bindings))"><font style=""><font class="Apple-style-span" color="#000000"><span class="Apple-style-span" style="text-decoration: none;"><font class="Apple-style-span" face="Arial">extract-bindings</font></span></font></font></a></font><font size="4" style="font: 13.0px Courier"><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial"> </font></font></font><font size="4" style="font: normal normal normal 13px/normal Courier; "><i><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial">key?</font></font></i></font><font size="4" style="font: 13.0px Courier"><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial"> </font></font></font><font size="4" style="font: normal normal normal 13px/normal Courier; "><i><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial">bindings</font></font></i></font><font size="4" style="font: normal normal normal 13px/normal Courier; "><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial">)</font></font></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font size="4" style="font: normal normal normal 13px/normal Courier; "><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial">(</font></font><a href="http://docs.plt-scheme.org/net/cgi.html#(def._((lib._net/cgi..ss)._extract-binding/single))"><font style=""><font class="Apple-style-span" color="#000000"><span class="Apple-style-span" style="text-decoration: none;"><font class="Apple-style-span" face="Arial">extract-binding/single</font></span></font></font></a></font><font size="4" style="font: 13.0px Courier"><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial"> </font></font></font><font size="4" style="font: normal normal normal 13px/normal Courier; "><i><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial">key?</font></font></i></font><font size="4" style="font: 13.0px Courier"><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial"> </font></font></font><font size="4" style="font: normal normal normal 13px/normal Courier; "><i><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial">bindings</font></font></i></font><font size="4" style="font: normal normal normal 13px/normal Courier; "><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial">)</font></font></font><font size="4" style="font: 13.0px Courier"><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial"><font style=""></font></font></font></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial"><br></font></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial">It seems pretty straightforward when it comes to simple form values, but not so with a file upload...</font></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial">Can I get both the file name and the file content through the bindings functions ?</font></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial">Has anybody a simple cgi script dealing with file upload, laying around ?</font></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial"><br></font></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial">Thanks</font></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial"><br></font></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial">E. </font></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Arial"><br></font></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#0000FF"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#0000FF"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#0000FF"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#0000FF"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#0000FF"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#0000FF"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#0000FF"><br></font></div></div></div></span></font></div></div></div> </body></html>