|
From: Tony C. <t.c...@su...> - 2024-12-01 19:24:11
|
Hello all,
I am getting something slightly wrong and I'm not sure what. This is still new to me, so likely I am making a silly error.
I want to provide users with a form that allows them to upload PDF files from their PC to the database. The form will also have information about the PDF, which is working as expected.
For a test I have two XQueries one to post the data and the other to save it:
xquery version "3.1";
declare option exist:serialize "method=html media-type=text/html indent=no";
<html><body>
<p>file upload test</p>
<form method="post" enctype="multipart/form-data" action="./storeFile.xql">
<input type="file" id="myFile" name="posted"/>
<input type="submit"/>
</form>
</body></html>
and
xquery version "3.1";
declare option exist:serialize "method=html media-type=text/html indent=no";
declare variable $received := request:get-parameter("posted",());
let $filePath :="/db/apps/scratch/data/files"
let $fileName := "test.pdf"
return
<html><body>Received {($filePath, $fileName, xmldb:store-as-binary($filePath, $fileName, $received))}</body></html>
The result is that I get a file test.pdf in the target directory but it displays only as blank pages. The same file uploaded through the admin client displays correctly.
(I get the same result with a side range of PDF files. If I change to store a JPG then I get a blank image from the XQuery route and the expected image using the admin client.)
I feel that I am missing something that is obvious and trivial to those who know what they are doing!
Any input welcome.
Tony
|