Hi,
I try to upload a binary file to MarkLogic, but it seems the
result of xdmp:get-request-field('file') seems to be always of
length 0. Here is a simple repro:
<!-- upload.html -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>What did I do wrong?</title>
</head>
<body>
<form action="upload.xqy" method="post"
enctype="multipart/form-data">
<p>
File: <input type="file" name="file"/>
<input type="submit" value="Go!"/>
</p>
</form>
</body>
</html>
(: upload.xqy :)
xquery version "1.0";
declare namespace xdmp = "http://marklogic.com/xdmp";
let $filename := xdmp:get-request-field-filename('file')
let $dispo := fn:concat('attachment; filename="', $filename, '"')
let $x := xdmp:add-response-header('Content-Disposition', $dispo)
let $x:= xdmp:set-response-content-type(
xdmp:get-request-field-content-type('file'))
return
xdmp:get-request-field('file')
This is based on the example in the xdmp:get-request-field doc
<http://xqzone.marklogic.com/pubs/4.1/apidocs/AppServerBuiltins.html#xdmp:get-request-field>.
If you put those two files on your HTTP app server, access the
HTML file, fill in the form and submit it, you get your file
back, with the same MIME type and filename, but the content is
empty.
I guess I missed the obvious, but I cannot see what I did
wrong.
Regards,
--
Florent Georges
http://www.fgeorges.org/
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general