annotate tests/blob.ur @ 737:d049d31a1966

Initial support for blobs and upload
author Adam Chlipala <adamc@hcoop.net>
date Sat, 25 Apr 2009 13:59:11 -0400
parents
children 4bb7e1c0550a
rev   line source
adamc@737 1 sequence s
adamc@737 2 table t : { Id : int, Nam : option string, Data : blob, Desc : string }
adamc@737 3
adamc@737 4 fun save r =
adamc@737 5 if numFiles r.Data <> 1 then
adamc@737 6 error <xml>Please submit exactly one file.</xml>
adamc@737 7 else
adamc@737 8 let
adamc@737 9 val f = fileNum r.Data 0
adamc@737 10 in
adamc@737 11 id <- nextval s;
adamc@737 12 dml (INSERT INTO t (Id, Nam, Data, Desc) VALUES ({[id]}, {[fileName f]}, {[fileData f]}, {[r.Desc]}));
adamc@737 13 main ()
adamc@737 14 end
adamc@737 15
adamc@737 16 and main () = return <xml><body>
adamc@737 17 <form>
adamc@737 18 <textbox{#Desc}/>
adamc@737 19 <upload{#Data}/>
adamc@737 20 <submit action={save}/>
adamc@737 21 </form>
adamc@737 22 </body></xml>