React FileUploader Props
abortUpload
A Promise that is resolved after the upload in aborted. It is a native Promise or a jQuery.Promise when you use jQuery.
- <template>
- <DxFileUploader ...
- :abort-upload="fileUploader_abortUpload"
- />
- </template>
- <script>
- import 'devextreme/dist/css/dx.light.css';
- import DxFileUploader from 'devextreme-vue/file-uploader';
- export default {
- components: {
- DxFileUploader
- },
- methods: {
- fileUploader_abortUpload(file, uploadInfo) {
- // ...
- }
- }
- }
- </script>
accept
The value of this property is passed to the accept attribute of the underlying input element. Thus, the property accepts a MIME type or several types separated by a comma. Refer to the input element documentation for information on available values.
accessKey
The value of this property will be passed to the accesskey
attribute of the HTML element that underlies the UI component.
allowCanceling
If this property is set to true, a cancel button is displayed for each selected file.
chunkSize
Specifies the chunk size in bytes. Applies only if uploadMode is "instantly" or "useButtons". Requires a server that can process file chunks.
Set this property to a positive value to enable chunk upload. The UI component should be configured as described in the Chunk Upload article. When chunk upload is enabled, the FileUploader sends several multipart/form-data requests with information about the file and chunk. The "chunkMetadata" parameter contains chunk details as a JSON object of the following structure:
- {
- "FileGuid": string,
- "FileName": string,
- "FileType": string,
- "FileSize": long,
- "Index": long, // The chunk's index
- "TotalCount": long, // The file's total chunk count
- }
See Also
dialogTrigger
You can use a selector string, jQuery object or DOM element to specify the dialogTrigger property:
String
JavaScript- dialogTrigger: '.open-button'
jQuery object
JavaScript- dialogTrigger: $('.open-button')
DOM element
JavaScript- dialogTrigger: $('.open-button')[0]
dropZone
You can use a selector string, jQuery object or DOM element to specify the dropZone property:
String
JavaScript- dropZone: '.test-div'
jQuery object
JavaScript- dropZone: $('.test-div')
DOM element
JavaScript- dropZone: $('.test-div')[0]
See Also
elementAttr
Specifies the global attributes to be attached to the UI component's container element.
- <template>
- <DxFileUploader ...
- :element-attr="fileUploaderAttributes">
- </DxFileUploader>
- </template>
- <script>
- import DxFileUploader from 'devextreme-vue/file-uploader';
- export default {
- components: {
- DxFileUploader
- },
- data() {
- return {
- fileUploaderAttributes: {
- id: 'elementId',
- class: 'class-name'
- }
- }
- }
- }
- </script>
height
This property accepts a value of one of the following types:
Number
The height in pixels.String
A CSS-accepted measurement of height. For example,"55px"
,"80%"
,"inherit"
.Function
A function returning either of the above. For example:JavaScript- height: function() {
- return window.innerHeight / 1.5;
- }
hoverStateEnabled
Specifies whether the FileUploader component changes the state of all its buttons when users hover over them.
invalidFileExtensionMessage
The text displayed when the extension of the file being uploaded is not an allowed file extension.
invalidMaxFileSizeMessage
The text displayed when the size of the file being uploaded is greater than the maxFileSize.
invalidMinFileSizeMessage
The text displayed when the size of the file being uploaded is less than the minFileSize.
isValid
The FileUploader provides alternative validation properties: maxFileSize, minFileSize, and allowedFileExtensions.
maxFileSize
Specifies the maximum file size (in bytes) allowed for uploading. Applies only if uploadMode is "instantly" or "useButtons".
minFileSize
Specifies the minimum file size (in bytes) allowed for uploading. Applies only if uploadMode is "instantly" or "useButtons".
name
Specifies the value passed to the name attribute of the underlying input element. Required to access uploaded files on the server.
See Also
onBeforeSend
Name | Type | Description |
---|---|---|
component |
The UI component's instance. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
file |
An uploaded file. |
|
model |
Model data. Available only if Knockout is used. |
|
request |
An XMLHttpRequest for the file. |
|
uploadInfo |
An object that provides information about the file upload session. |
- <template>
- <DxFileUploader
- :on-before-send="onBeforeSend" >
- </DxFileUploader>
- </template>
- <script>
- import 'devextreme/dist/css/dx.light.css';
- import {
- DxFileUploader
- // ...
- } from 'devextreme-vue/file-uploader';
- export default {
- components: {
- DxFileUploader
- // ...
- },
- methods: {
- onBeforeSend(e) {
- e.request.withCredentials = true;
- }
- },
- data() {
- return {
- //...
- };
- }
- };
- </script>
onContentReady
A function that is executed when the UI component's content is ready and each time the content is changed.
Name | Type | Description |
---|---|---|
component |
The UI component's instance. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
model |
Model data. Available only when using Knockout. |
onDisposing
A function that is executed before the UI component is disposed of.
Name | Type | Description |
---|---|---|
component |
The UI component's instance. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
model |
Model data. Available only if you use Knockout. |
onDropZoneEnter
Name | Type | Description |
---|---|---|
component |
The UI component's instance. |
|
dropZoneElement |
A drop zone element. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is a dxEvent or a jQuery.Event when you use jQuery. |
model |
Model data. Available only if Knockout is used. |
onDropZoneLeave
Name | Type | Description |
---|---|---|
component |
The UI component's instance. |
|
dropZoneElement |
A drop zone element. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is a dxEvent or a jQuery.Event when you use jQuery. |
model |
Model data. Available only if Knockout is used. |
onFilesUploaded
Name | Type | Description |
---|---|---|
component |
The UI component's instance. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
model |
Model data. Available only if Knockout is used. |
- <template>
- <DxFileUploader
- :on-files-uploaded="onFilesUploaded" >
- </DxFileUploader>
- </template>
- <script>
- import 'devextreme/dist/css/dx.light.css';
- import {
- DxFileUploader
- // ...
- } from 'devextreme-vue/file-uploader';
- export default {
- components: {
- DxFileUploader
- // ...
- },
- methods: {
- onFilesUploaded(e) {
- // ...
- }
- },
- data() {
- return {
- //...
- };
- }
- };
- </script>
onInitialized
Name | Type | Description |
---|---|---|
component |
The UI component's instance. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
onOptionChanged
Name | Type | Description |
---|---|---|
model |
Model data. Available only if you use Knockout. |
|
fullName |
The path to the modified property that includes all parent properties. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
component |
The UI component's instance. |
|
name |
The modified property if it belongs to the first level. Otherwise, the first-level property it is nested into. |
|
value | any |
The modified property's new value. |
The following example shows how to subscribe to component property changes:
- <template>
- <DxFileUploader ...
- @option-changed="handlePropertyChange"
- />
- </template>
- <script>
- import 'devextreme/dist/css/dx.common.css';
- import 'devextreme/dist/css/dx.light.css';
- import DxFileUploader from 'devextreme-vue/file-uploader';
- export default {
- components: {
- DxFileUploader
- },
- // ...
- methods: {
- handlePropertyChange: function(e) {
- if(e.name === "changedProperty") {
- // handle the property change here
- }
- }
- }
- }
- </script>
onProgress
Name | Type | Description |
---|---|---|
bytesLoaded |
The total count of the uploaded bytes. |
|
bytesTotal |
The total count of bytes in the XMLHttpRequest. |
|
component |
The UI component's instance. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is a dxEvent or a jQuery.Event when you use jQuery. |
file |
An uploaded file. |
|
model |
Model data. Available only if Knockout is used. |
|
request |
An XMLHttpRequest for the file. |
|
segmentSize |
The size of the uploaded file segment. |
onUploadAborted
Name | Type | Description |
---|---|---|
component |
The UI component's instance. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is a dxEvent or a jQuery.Event when you use jQuery. |
file |
The uploaded file. |
|
message |
The message displayed by the UI component when the file upload is cancelled. |
|
model |
Model data. Available only if Knockout is used. |
|
request |
Specifies an XMLHttpRequest for the file. |
onUploaded
Name | Type | Description |
---|---|---|
component |
The UI component's instance. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is a dxEvent or a jQuery.Event when you use jQuery. |
file |
The uploaded file. |
|
message |
The message displayed by the UI component when uploading is finished. |
|
model |
Model data. Available only if Knockout is used. |
|
request |
Specifies an XMLHttpRequest for the file. |
onUploadError
Name | Type | Description |
---|---|---|
component |
The UI component's instance. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
error | any |
The error that occurred. |
event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is a dxEvent or a jQuery.Event when you use jQuery. |
file |
The uploaded file. |
|
message |
The message displayed by the UI component on uploading failure. |
|
model |
Model data. Available only if Knockout is used. |
|
request |
Specifies an XMLHttpRequest for the file. |
The following code shows how you can handle a network error.
- <template>
- <DxFileUploader
- :on-upload-error="onUploadError" >
- </DxFileUploader>
- </template>
- <script>
- import 'devextreme/dist/css/dx.light.css';
- import {
- DxFileUploader
- // ...
- } from 'devextreme-vue/file-uploader';
- export default {
- components: {
- DxFileUploader
- // ...
- },
- methods: {
- onUploadError(e) {
- var xhttp = e.request;
- if (xhttp.readyState == 4 && xhttp.status == 0) {
- console.log("Connection refused.");
- }
- }
- },
- data() {
- return {
- //...
- };
- }
- };
- </script>
See Also
onUploadStarted
Name | Type | Description |
---|---|---|
component |
The UI component's instance. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is a dxEvent or a jQuery.Event when you use jQuery. |
file |
The uploaded file. |
|
model |
Model data. Available only if Knockout is used. |
|
request |
Specifies an XMLHttpRequest for the file. |
onValueChanged
Name | Type | Description |
---|---|---|
value |
Newly selected files. |
|
previousValue |
Previously selected files. |
|
model |
Model data. Available only if Knockout is used. |
|
event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is a dxEvent or a jQuery.Event when you use jQuery. This field is undefined if the value is changed programmatically. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
component |
The UI component's instance. |
readOnly
Set the readOnly property to true to enable the following functionality:
- File upload in UI is disabled. This also includes a HTML element specified in the dialogTrigger property.
- Built-in action buttons are disabled.
Note that already selected files are available for upload in readOnly mode.
readyToUploadMessage
This property makes sense only if the uploadMode property is set to "useButtons".
rtlEnabled
When this property is set to true, the UI component text flows from right to left, and the layout of elements is reversed. To switch the entire application/site to the right-to-left representation, assign true to the rtlEnabled field of the object passed to the DevExpress.config(config) method.
- DevExpress.config({
- rtlEnabled: true
- });
tabIndex
The value of this property will be passed to the tabindex
attribute of the HTML element that underlies the UI component.
uploadAbortedMessage
This property is only available if the uploadMode property is set to "instantly".
uploadButtonText
The property makes sense only if the uploadMode property is set to "useButtons" or "instantly".
uploadChunk
A Promise that is resolved after the chunk is uploaded. It is a native Promise or a jQuery.Promise when you use jQuery.
- <template>
- <DxFileUploader ...
- :upload-chunk="fileUploader_uploadChunk"
- />
- </template>
- <script>
- import 'devextreme/dist/css/dx.light.css';
- import DxFileUploader from 'devextreme-vue/file-uploader';
- export default {
- components: {
- DxFileUploader
- },
- methods: {
- fileUploader_uploadChunk(file, uploadInfo) {
- // ...
- }
- }
- }
- </script>
uploadCustomData
- <template>
- <DxFileUploader
- :upload-custom-data="uploaderCustomData" >
- </DxFileUploader>
- </template>
- <script>
- import 'devextreme/dist/css/dx.light.css';
- import {
- DxFileUploader
- } from 'devextreme-vue/file-uploader';
- export default {
- components: {
- DxFileUploader
- },
- data() {
- return {
- uploaderCustomData: {
- __RequestVerificationToken: document.getElementsByName("__RequestVerificationToken")[0].value
- }
- };
- }
- };
- </script>
uploadedMessage
The property makes sense only if the uploadMode property is set to "useButtons" or "instantly".
uploadFailedMessage
The property makes sense only if the uploadMode property is set to "useButtons" or "instantly".
uploadFile
A Promise that is resolved after the file is uploaded. It is a native Promise or a jQuery.Promise when you use jQuery.
A Promise that is resolved after the file is uploaded. It is a native Promise or a jQuery.Promise when you use jQuery.
- <template>
- <DxFileUploader ...
- :upload-file="fileUploader_uploadFile"
- />
- </template>
- <script>
- import 'devextreme/dist/css/dx.light.css';
- import DxFileUploader from 'devextreme-vue/file-uploader';
- export default {
- components: {
- DxFileUploader
- },
- methods: {
- fileUploader_uploadFile(file, progressCallback) {
- // your code
- progressCallback(100);
- // ...
- progressCallback(200);
- // ...
- }
- }
- }
- </script>
uploadMethod
The property makes sense only if the uploadMode property is set to "useButtons" or "instantly".
uploadMode
Depending on the uploadMode, the FileUploader UI component uses an HTML form or a FormData interface with a series of Ajax requests to upload files. The uploadMode property accepts one of the following values:
"instantly" (default)
Ajax upload. Files are uploaded after they are selected."useButtons"
Ajax upload. Files are uploaded after a user clicks the Upload button."useForm"
HTML form upload. Files are uploaded when the HTML form is submitted.
See Also
uploadUrl
The property makes sense only if the uploadMode property is set to "useButtons" or "instantly".
validationError
Information on the broken validation rule. Contains the first item from the validationErrors array.
value
Specifies a File instance representing the selected file. Read-only when uploadMode is "useForm".
width
This property accepts a value of one of the following types:
Number
The width in pixels.String
A CSS-accepted measurement of width. For example,"55px"
,"80%"
,"auto"
,"inherit"
.Function
A function returning either of the above. For example:JavaScript- width: function() {
- return window.innerWidth / 1.5;
- }
If you have technical questions, please create a support ticket in the DevExpress Support Center.