From: Tony C. <t.c...@su...> - 2024-12-02 17:44:28
|
Thanks Joe and Jean-Paul As you’d expect things are now working exactly as I’d hoped. Tony From: Joe Wicentowski <jo...@gm...> Sent: 02 December 2024 17:16 To: Corless, Tony (Comp Sci & Elec Eng) <t.c...@su...> Cc: exi...@li... Subject: Re: [Exist-open] Help with file upload please. Hi Tony, Instead of the request:get-parameter function, use request:get-uploaded-file-data. See: https://exist-db.org/exist/apps/fundocs/view.html?uri=http://exist-db.org/xquery/request#get-uploaded-file-data.1 Joe On Mon, Dec 2, 2024 at 4:20 AM Tony Corless via Exist-open <exi...@li...<mailto:exi...@li...>> wrote: 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 _______________________________________________ Exist-open mailing list Exi...@li...<mailto:Exi...@li...> https://lists.sourceforge.net/lists/listinfo/exist-open |