How to upload a blob in Velocity?

There are some options.

  1. Use a HTML form

    In this example we have a form in /upload/form.vm This form needs to use the post method and enctype multipart/form-data. You can only submit files in this way. Other inputs types will not be included in the post parameters. You can use the action url to include parameters. For instance: /upload/form.vm?foo=bar parameter can be asked with $request.get('foo') You can use the multiple attribute on the file input, to upload multiple files at the same time.

    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    This will be submitted to /upload/action.vm Here we get all the blobs (files). With a #foreach loop we loop over the blobs and put each one in the field image of a record that has the class image.

    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  2. Use JavaScript and AJAX

    In this example we have a similar form in  /upload/ajax_form.vm When using JavaScript (and AJAX) the same rules apply. We need the post method and enctype multipart/form-data

    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    From the file /upload/ajax_action.vm you can return a message on success or failure. In the example above this gets logged in the browser console.