.. include:: ../Includes.txt .. _examples_axios_fileuploads: ============ Uploading Files ============ .. hint:: This chapter explains how to upload files to the ``nnrestapi`` using the JavaScript library **axios**. If you are interested in finding out, how to create an endpoint that processes the fileupload, attaches the SysFileReference to a model and then persists the model in the database, please refer to the examples in :ref:`this section ` How to upload files using the axios library ------------ .. tip:: You can find a full example with fileuploads and axios here: `play on CodePen `__ Using mutipart form-data ~~~~~~~~~~~~ Please refer to :ref:`this section ` for detailled information on implementing the backend part of the file-upload. By default, the nnrestapi will recursively iterate through the JSON from your request and look for the special placeholder ``UPLOAD:/varname``. If it finds a fileupload in the multipart/form-data corresponding to the ``varname`` of the placeholder, it will automatically move the file to its destination and replace the ``UPLOAD:/varname`` in the JSON with the path to the file, e.g. ``fileadmin/api/image.jpg``. Here is a basic example on creating a multipart/form-data request using axios. First, let's create a simple form in HTML. As we are retrieving the input-values manually, there is no need to wrap the inputs in a ``
`` element: .. code-block:: html