<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><font class="Apple-style-span" face="Arial">hello</font><div><font class="Apple-style-span" face="Arial"><br></font></div><div><font class="Apple-style-span" face="Arial">I've just read "Continue: Web Applications in PLT Scheme"</font></div><div><font class="Apple-style-span" face="Arial">and started modifying the blog application.</font></div><div><font class="Apple-style-span" face="Arial"><br></font></div><div><font class="Apple-style-span" face="Arial">I want to add a file upload form but I got stuck...</font></div><div><font class="Apple-style-span" face="Arial"><br></font></div><div><font class="Apple-style-span" face="Arial"><br></font></div><div><font class="Apple-style-span" face="Arial">the code generating the form is:</font></div><div><font class="Apple-style-span" face="Arial"><br></font></div><div><span class="Apple-style-span" style="font-family: Arial; ">(form ((action ,(make-url add-image))</span></div><div><font class="Apple-style-span" face="Arial"><div> (method "post")</div><div> (enctype "multipart/form-data"))</div><div> (input ((type "file")(name "image")))</div><div> (input ((type "submit"))))</div></font></div><div><font class="Apple-style-span" face="Arial"><br></font></div><div><font class="Apple-style-span" face="Arial"><br></font></div><div><font class="Apple-style-span" face="Arial">I am not sure how to write add-image, more precisely, I am not sure what type of data (extract-binding/single 'image bindings) is...</font></div><div><font class="Apple-style-span" face="Arial">My hunch is that it is a binary stream (the file data), so I tried:</font></div><div><font class="Apple-style-span" face="Arial"><br></font></div><div><font class="Apple-style-span" face="Arial"><div>(define (add-image request)</div><div> (define bindings (request-bindings request))</div><div> (save-image! (extract-binding/single 'image bindings) "image.jpg")</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> ...<br></div><div> )</div></font></div><div><font class="Apple-style-span" face="Arial"><br></font></div><div><font class="Apple-style-span" face="Arial">where</font></div><div><font class="Apple-style-span" face="Arial"><br></font></div><div><div>(define (save-image! image-data image-name)</div><div> (with-output-to-file (build-path (find-system-path 'home-dir) image-name)</div><div> (lambda () (write image-data))</div><div> #:exists 'replace))</div><div><br></div><div><br></div><div>but this gives the following exception:</div><div><br></div><div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 16px; margin-left: 5px; "><font face="Helvetica" size="5" style="font: normal normal normal 16px/normal Helvetica; ">The application raised an exception with the message:</font></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; background-color: rgb(255, 203, 255); "><font face="Courier" size="4" style="font: normal normal normal 13px/normal Courier; ">you broke the contract xexpr? on start; Not an Xexpr. Expected a string, symbol, number, comment, processing instruction, or list, given #<void></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Courier; background-color: rgb(255, 203, 255); min-height: 16px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; background-color: rgb(255, 203, 255); "><font face="Courier" size="4" style="font: normal normal normal 13px/normal Courier; ">Context:</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; background-color: rgb(255, 203, 255); "><font face="Courier" size="5" color="#ff0000" style="font: normal normal normal 16px/normal Courier; color: rgb(255, 0, 0); ">#</font></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 16px; margin-left: 5px; font: normal normal normal 16px/normal Helvetica; min-height: 19px; "><br></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 16px; margin-left: 5px; "><font face="Helvetica" size="5" style="font: normal normal normal 16px/normal Helvetica; ">Stack trace:</font></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; background-color: rgb(255, 203, 255); "><font face="Courier" size="4" style="font: normal normal normal 13px/normal Courier; "><unknown procedure> at:</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; background-color: rgb(255, 203, 255); "><font face="Courier" size="4" style="font: normal normal normal 13px/normal Courier; "> line 18, column 5, in file /Applications/PLT Scheme v4.2/collects/web-server/private/xexpr.ss</font></div></div><div><br></div><div><br></div><div>Any idea what went wrong ?</div><div>Is there any examples online of web app written with PLT, beside the Continue tutorial ?</div><div><br></div><div>Thanks</div><div><br></div><div>E.D</div><div><br></div><div><br></div><div><p style="margin: 0.0px 0.0px 16.0px 5.0px"><br></p><p style="margin: 0.0px 0.0px 16.0px 5.0px"><br></p><p style="margin: 0.0px 0.0px 16.0px 5.0px"><br></p><p style="margin: 0.0px 0.0px 16.0px 5.0px"><font class="Apple-style-span" size="4"><span class="Apple-style-span" style="font-size: 16px;"><br></span></font></p></div></div></body></html>