|
@@ -22,42 +22,46 @@ uppy.use(XHRUpload, {
|
|
|
|
|
|
This plugin is published as the `@uppy/xhr-upload` package.
|
|
|
|
|
|
+Install from NPM:
|
|
|
+
|
|
|
```shell
|
|
|
npm install @uppy/xhr-upload
|
|
|
```
|
|
|
|
|
|
## Options
|
|
|
|
|
|
+The XHRUpload plugin has the following configurable options:
|
|
|
+
|
|
|
### `id: 'XHRUpload'`
|
|
|
|
|
|
-A unique identifier for this plugin. Defaults to `'XHRUpload'`.
|
|
|
+A unique identifier for this plugin. It defaults to `'XHRUpload'`.
|
|
|
|
|
|
### `endpoint: ''`
|
|
|
|
|
|
-URL to upload to.
|
|
|
+The destination URL for your uploads.
|
|
|
|
|
|
### `method: 'post'`
|
|
|
|
|
|
-HTTP method to use for the upload.
|
|
|
+Configures which HTTP method to use for the upload.
|
|
|
|
|
|
### `formData: true`
|
|
|
|
|
|
-Whether to use a multipart form upload, using [FormData][].
|
|
|
+Configures whether or not to use a multipart form upload, using [FormData][].
|
|
|
This works similarly to using a `<form>` element with an `<input type="file">` for uploads.
|
|
|
-When `true`, file metadata is also sent to the endpoint as separate form fields.
|
|
|
-When `false`, only the file contents are sent.
|
|
|
+When set to `true`, file metadata is also sent to the endpoint as separate form fields.
|
|
|
+When set to `false`, only the file contents are sent.
|
|
|
|
|
|
### `fieldName: 'files[]'`
|
|
|
|
|
|
-When `formData` is true, this is used as the form field name for the file to be uploaded.
|
|
|
+When `formData` is set to true, this is used as the form field name for the file to be uploaded.
|
|
|
|
|
|
### `metaFields: null`
|
|
|
|
|
|
Pass an array of field names to limit the metadata fields that will be sent to the endpoint as form fields.
|
|
|
For example, `metaFields: ['name']` will only send the `name` field.
|
|
|
-Passing `null` (the default) will send *all* metadata fields.
|
|
|
+Setting this to `null` (the default) will send *all* metadata fields.
|
|
|
|
|
|
-If the `formData` option is false, `metaFields` has no effect.
|
|
|
+If the `formData` option is set to false, `metaFields` has no effect.
|
|
|
|
|
|
### `headers: {}`
|
|
|
|
|
@@ -72,9 +76,9 @@ headers: {
|
|
|
|
|
|
### `bundle: false`
|
|
|
|
|
|
-Send all files in a single multipart request. When `bundle` is `true`, `formData` must also be set to `true`.
|
|
|
+Send all files in a single multipart request. When `bundle` is set to `true`, `formData` must also be set to `true`.
|
|
|
|
|
|
-> Note: When `bundle` is `true`, file metadata is **not** sent to the endpoint. This is because it's not obvious how metadata should be sent when there are multiple files in a single request. If you need this, please open an issue and we'll try to figure it out together.
|
|
|
+> Note: When `bundle` is set to `true`, file metadata is **not** sent to the endpoint. This is because it is not obvious how metadata should be sent when there are multiple files in a single request. If you need this, please open an issue and we will try to figure it out together.
|
|
|
|
|
|
All files will be appended to the provided `fieldName` field in the request. To upload files on different fields, use [`uppy.setFileState()`](/docs/uppy#uppy-setFileState-fileID-state) to set the `xhrUpload.fieldName` property on the file:
|
|
|
|
|
@@ -156,11 +160,11 @@ When no upload progress events have been received for this amount of millisecond
|
|
|
Note that unlike the [`XMLHttpRequest.timeout`][XHR.timeout] property, this is a timer between progress events: the total upload can take longer than this value.
|
|
|
Set to `0` to disable this check.
|
|
|
|
|
|
-The default is 30 seconds.
|
|
|
+The default for the timeout is 30 seconds.
|
|
|
|
|
|
### `limit: 0`
|
|
|
|
|
|
-Limit the amount of uploads going on at the same time. Passing `0` means no limit.
|
|
|
+Limit the amount of uploads going on at the same time. Setting this to `0` means there is no limit on concurrent uploads.
|
|
|
|
|
|
### `withCredentials: false`
|
|
|
|
|
@@ -219,7 +223,7 @@ $file_name = $_POST['name']; // desired name of the file
|
|
|
move_uploaded_file($file_path, './img/' . basename($file_name)); // save the file in `img/`
|
|
|
```
|
|
|
|
|
|
-Note how we're using `$_POST['name']` instead of `$my_file['name']`. `$my_file['name']` contains the original name of the file on the user's device. `$_POST['name']` contains the `name` metadata value for the uploaded file, which can be edited by the user using the [Dashboard](/docs/dashboard).
|
|
|
+Note how we are using `$_POST['name']` instead of `$my_file['name']`. `$my_file['name']` contains the original name of the file on the user's device. `$_POST['name']` contains the `name` metadata value for the uploaded file, which can be edited by the user using the [Dashboard](/docs/dashboard).
|
|
|
|
|
|
Set a custom `fieldName` to make working with the `$_FILES` array a bit less convoluted:
|
|
|
|