Skip to content
blueimp edited this page May 19, 2011 · 158 revisions

The jQuery File Upload Plugin consists of a basic version (jquery.fileupload.js) providing the basic File Upload API and an additional plugin providing a complete user interface (jquery.fileupload-ui.js).
All options of the basic version are present in the UI version, while the latter introduces some additional options.

For example code on how to use the options, please refer to the API documentation.

Options for the basic jQuery File Upload Plugin

namespace

The namespace used for event handler binding on the dropZone and fileInput collections.
If not set, the name of the widget ("fileupload") is used.

  • Type: String
  • Example: 'myfileupload'

dropZone

The drop target jQuery object, by the default the complete document.
Set to null or an empty collection to disable drag & drop support:

  • Type: jQuery Object
  • Default: $(document)

fileInput

The file input field jQuery object, that is listened for change events.
If undefined, it is set to the file input fields inside of the widget element on plugin initialization.
Set to null or an empty collection to disable the change listener.

  • Type: jQuery Object
  • Example: $('input:file')

replaceFileInput

By default, the file input field is replaced with a clone after each input field change event. This is required for iframe transport queues and allows change events to be fired for the same file selection, but can be disabled by setting this option to false.

  • Type: boolean
  • Default: true

paramName

The parameter name for the file form data (the request argument name).
If undefined or empty, the name property of the file input field is used, or "files[]" if the file input name property is also empty.

  • Type: string
  • Example: 'attachments[]'

singleFileUploads

By default, each file of a selection is uploaded using an individual request for XMLHttpRequest type uploads. Set this option to false to upload file selections in one request each.

Note: Uploading multiple files with one request requires the multipart option to be set to true (the default).

  • Type: boolean
  • Default: true

sequentialUploads

Set this option to true to issue all file upload requests in a sequential order instead of simultaneous requests.

  • Type: boolean
  • Default: false

forceIframeTransport

Set this option to true to force iframe transport uploads, even if the browser is capable of XMLHttpRequest file uploads.
This can be useful for cross-site file uploads, if the Access-Control-Allow-Origin header cannot be set for the server-side upload handler which is required for cross-site XMLHttpRequest file uploads.

  • Type: boolean
  • Default: false

multipart

By default, XMLHttpRequest file uploads are sent as multipart/form-data.
The iframe transport is always using multipart/form-data.
If this option is set to false, the file content is streamed to the server url instead of sending a RFC 2388 multipart message for XMLHttpRequest file uploads.
Non-multipart uploads are also referred to as HTTP PUT file upload.

Note: Additional form data is ignored when the multipart option is set to false.

  • Type: boolean
  • Default: true

maxChunkSize

To upload large files in smaller chunks, set this option to a preferred maximum chunk size. If set to 0, null or undefined, or the browser does not support the required Blob API, files will be uploaded as a whole. See also Chunked Uploads.

Note: If this option is enabled and singleFileUploads is set to false, only the first file of a selection will be uploaded.

  • Type: number
  • Default: undefined
  • Example: 10000000

uploadedBytes

When a non-multipart upload or a chunked multipart upload has been aborted, this option can be used to resume the upload by setting it to the size of the already uploaded bytes. This option is most useful when modifying the options object inside of the "add" or "send" callbacks, as the options are cloned for each file upload. See also Chunked Uploads.

  • Type: number
  • Default: undefined
  • Example: 10000000

recalculateProgress

By default, failed (abort or error) file uploads are removed from the global progress calculation. Set this option to false to prevent recalculating the global progress data.

  • Type: boolean
  • Default: true

formData

Additional form data to be sent along with the file uploads can be set using this option, which accepts an array of objects with name and value properties, a function returning such an array, a FormData object (for XMLHttpRequest file uploads), or a simple object.
The form of the first fileInput is given as parameter to the function.

Note: Additional form data is ignored when the multipart option is set to false.

  • Type: Array, Object, function or FormData
  • Default: A function returning the form fields as serialized Array:
function (form) {
    return form.serializeArray();
}
  • Example:
[
  {
    name: 'a',
    value: 1
  },
  {
    name: 'b',
    value: 2
  }
]

Clone this wiki locally