XQuery/Uploading Files

Motivation
You want to upload files to your eXist database using simple HTML forms.

Method
We will use the HTML element in the web form and the store function in an XQuery.

HTML Form
We will use a standard HTML form but we will add a enctype="multipart/form-data" attribute.

Screen Image:

XQuery
On the server side, we will use the request:get-uploaded-file-name to get the name of the incoming file and the request:get-uploaded-file-data function to get the data from the file. We can then used the xmldb:store function to save the file.

File: upload.xq

Acknowledgments
This example was posted on the eXist open mailing list by Rémi Arnaud on Nov. 05, 2010.