Here's the important bits of the HTML form from one of our apps, which
looks to be the same as yours except for the xmlns="" bit.

        <form name="test"
              action="upload.xqy"
              method="post"
              enctype="multipart/form-data"
              xmlns="">
          <input name="docFile" type="file" 
onchange="javascript:preview(this)"/>
          <input type="submit" value="Upload"/>
        </form>

Here is how it gets inserted into the database, which again looks very
much like what you're doing.

        xdmp:document-insert(
          $furi,
          xdmp:get-request-field("docFile"),
          $perms)

In the html you provided, I don't see a space before method="post" but
I'm assuming that's just a copy/paste error.

What behavior are you seeing?

Does it work if you simplify the "$body := ..." line down to just
calling xdmp:get-request-field()?

Wayne.


On Mon, 2009-11-02 at 14:40 -0800, Keith L. Breinholt wrote:
> 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>Fileto 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 $typeeq
> "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]
> 
> "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