5.15.0

Request Parameters

The requests that Fine Uploader makes to your server are arguably the most crucial part of the uploading process. Fortunately, modifying the request is a fairly trivial task thanks to a few helpful options and methods provided by Fine Uploader.

Request parameters can be modified foremost by changing the values of the following options found in the request option:

Fine Uploader S3's request option

The request option properties are a bit different if you are using Fine Uploader S3. Here are the only properties of the request option used by Fine Uploader S3.


The params option is used to define request parameters when you instantiate a new Fine Uploader instance. Parameters defined this way are set on the request at the very last minute before it is sent to the server. Parameters can also be set for delete file requests. Simply modify the params property of the deleteFile option. Either of these properties are capable of handling a variety of JavaScript objects.

Simple Objects

params: {
    username: "mark",
    date: new Date()
}

Nested Objects

params: {
    user: {
        username: 'mark',
        firstName: 'Mark',
        lastName: 'Twain'
    }
}

Functions

Yes, even functions! (They are first-class citizens in JS world)

Each function will be evaluated for each file that is submitted. The following code snippet demonstrates how one would track the current number of uploaded files.

var fileNum = 0;

// ...

    params: {
        fileNum: function () {
            return fileNum++;
        }
    }

Note

Any params with a function value must return either a number or a string.

For more information, see the associated blog post

Methods

The setParams and setDeleteFileParams methods can be used to change parameters passed at any point in the upload process (well, at any point up until the file is uploaded). For the current file, you can adjust the passed parameters along with the request as late as when the upload event is fired. Parameters can also be modified for a file in the manualRetry and autoRetry events.

setParams can change the parameters for a all files, or for a single file by providing an optional id parameter.

Note

Once you change parameters for a specific file, subsequent calls to setParams without an id will not affect this file. To change parameters again, call setParams again with the associated id.

URL Query String Parameters

Sometimes it may prove useful to send request parameters in the URL query string, and fortunately Fine Uploader supports this right out of the box. By disabling the request.paramsInBody option, you can pass parameters through the query string rather than the request body.

Note

All parameters in the query string are URI Component Encoded. This means that you must decode the parameter keys and values server-side. JavaScript's encodeURIComponent function uses the UTF-8 encoding scheme so make sure that your server is using the same encoding. Lastly, be sure to the meta tag in your HTML: <meta charset='utf-8'>

For more information, see the associated blog post