What is the correct way of receiving a 'POST'ed file?

With the following HTML form and post-any.xqy code pass/post file of most any 
type except JPG.

html xmlns="http://www.w3.org/1999/xhtml";>
    <body>
        <form name="test" action="post-any.xqy" method="post" 
enctype="multipart/form-data">
            <p>File to upload: <input type="file" name="upload" /></p>
            <p><input type="submit" value="Upload"/></p>
        </form>
    </body>
</html>

Contents of post-any.xqy

let $filename := xdmp:get-request-field-filename( "upload" )
let $type := xdmp:get-request-field-content-type( "upload" )
let $body :=
  if ( xdmp:get-request-method() eq "POST" or $type eq 
"application/x-www-form-urlencoded" )
  then xdmp:get-request-field("upload")
  else xdmp:get-request-body( xdmp:uri-format( $filename ) )
let $uri := concat( "/test/", $filename )
return xdmp:document-insert( $uri, $body )

What is the correct way of sending and receiving binary files?

Thanks,

Keith L. Breinholt
ICS Content & Media
[email protected]<mailto:[email protected]>
"Do what you can, with what you have, where you are." Theodore Roosevelt


 NOTICE: This email message is for the sole use of the intended recipient(s) 
and may contain confidential and privileged information. Any unauthorized 
review, use, disclosure or distribution is prohibited. If you are not the 
intended recipient, please contact the sender by reply email and destroy all 
copies of the original message.


_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to