Drag and Drop File Uploader With Ability to Preview Before Sumbiting
Upload
Upload file by selecting or dragging.
When To Use#
Uploading is the procedure of publishing information (web pages, text, pictures, video, etc.) to a remote server via a web page or upload tool.
- When yous need to upload one or more files.
- When yous need to show the process of uploading.
- When you lot need to upload files past dragging and dropping.
import { NzUploadModule } from 'ng-zorro-antd/upload' ;
Examples
Click or drag file to this area to upload
Support for a single or majority upload. Strictly prohibit from uploading company data or other band files
API#
You can consult jQuery-File-Upload most how to implement server side upload interface.
nz-upload #
Property | Clarification | Blazon | Default |
---|---|---|---|
[nzAccept] | File types that can be accustomed. Meet input accept Attribute | string | - |
[nzAction] | Required. Uploading URL | cord | ((file: NzUploadFile) => string | Appreciable<string>) | - |
[nzDirectory] | support upload whole directory (caniuse) | boolean | simulated |
[nzBeforeUpload] | Claw function which will be executed before uploading. Uploading will exist stopped with faux or a Observable. Warning:this function is not supported in IE9. Notice: Must utilise => to define the method. | (file: NzUploadFile, fileList: NzUploadFile[]) => boolean | Appreciable<boolean> | - |
[nzCustomRequest] | override for the default xhr behavior assuasive for additional customization and power to implement your own XMLHttpRequest. NOTICE: Must use => to define the method. | (particular) => Subscription | - |
[nzData] | Uploading params or function which can return uploading params. NOTICE: Must use => to define the method. | Object | ((file: NzUploadFile) => Object | Observable<{}>) | - |
[nzDisabled] | disable upload button | boolean | fake |
[nzFileList] | List of files, two-way data-bounden | NzUploadFile[] | - |
[nzLimit] | limit single upload count when nzMultiple has opened. 0 unlimited | number | 0 |
[nzSize] | limit file size (KB). 0 unlimited | number | 0 |
[nzFileType] | limit file blazon, due east.g: paradigm/png,image/jpeg,paradigm/gif,image/bmp | string | - |
[nzFilter] | Custom filter when choosed file | UploadFilter[] | - |
[nzHeaders] | Set request headers, valid above IE10. NOTICE: Must use => to define the method. | Object | ((file: NzUploadFile) => Object | Observable<{}>) | - |
[nzListType] | Built-in stylesheets, support for three types: text , moving picture or moving picture-menu | 'text' | 'pic' | 'motion picture-menu' | 'text' |
[nzMultiple] | Whether to back up selected multiple file. IE10+ supported. You tin select multiple files with CTRL holding downwardly while multiple is set to be true | boolean | false |
[nzName] | The name of uploading file | string | 'file' |
[nzShowUploadList] | Whether to testify default upload list, could be an object to specify showPreviewIcon , showRemoveIcon and showDownloadIcon individually | boolean | { showPreviewIcon?: boolean, showRemoveIcon?: boolean, showDownloadIcon?: boolean } | true |
[nzShowButton] | Show upload push button | boolean | truthful |
[nzWithCredentials] | ajax upload with cookie sent | boolean | simulated |
[nzOpenFileDialogOnClick] | click open file dialog | boolean | truthful |
[nzPreview] | A callback function, volition be executed when file link or preview icon is clicked. Discover: Must use => to define the method. | (file: NzUploadFile) => void | - |
[nzPreviewFile] | Customize preview file logic. Detect: Must utilise => to define the method. | (file: NzUploadFile) => Observable<dataURL: string> | - |
[nzPreviewIsImage] | Customize the preview file is an image, generally used when the prototype URL is in a non-standard format. NOTICE: Must utilize => to define the method. | (file: NzUploadFile) => boolean | - |
[nzRemove] | A callback function, will exist executed when removing file push button is clicked, remove event will be prevented when render value is simulated or a Observable. Observe: Must use => to define the method. | (file: NzUploadFile) => boolean | Observable<boolean> | - |
(nzChange) | A callback function, can be executed when uploading state is changing | EventEmitter<NzUploadChangeParam> | - |
[nzDownload] | Click the method to download the file, pass the method to perform the method logic, practise not pass the default leap to the new TAB. | (file: NzUploadFile) => void | Jump to new TAB |
[nzTransformFile] | Customize transform file before request | (file: NzUploadFile) => NzUploadTransformFileType | - |
[nzIconRender] | Custom show icon | TemplateRef<{ $implicit: NzUploadFile }> | - |
[nzFileListRender] | Custom file listing | TemplateRef<{ $implicit: NzUploadFile[] }> | - |
nzChange#
The office will exist chosen when uploading is in progress, completed or failed
When uploading state change, information technology returns:
{ file: { /* ... */ } , fileList: [ /* ... */ ] , outcome: { /* ... */ } , }
-
file
File object for the current performance.{ uid: 'uid' , // unique identifier name: '20.png' // file name condition: 'done' , // options:uploading, done, error, removed response: '{"status": "success"}' , // response from server linkProps: '{"download": "image"}' , // additional html props of file link }
-
fileList
current list of files -
event
response from server, including uploading progress, supported by advanced browsers.
nzCustomRequest#
Allows for advanced customization by overriding default behavior in HttpClient
. Provide your own XMLHttpRequest calls to interface with custom backend processes or interact with AWS S3 service through the aws-sdk-js parcel.
nzCustomRequest
callback is passed an object with:
-
onProgress: (result: { percent: number }): void
-
onError: (event: Mistake): void
-
onSuccess: (body: Object, xhr?: Object): void
-
data: Object
-
filename: String
-
file: File
-
withCredentials: Boolean
-
action: String
-
headers: Object
Source: https://ng.ant.design/components/upload/en
0 Response to "Drag and Drop File Uploader With Ability to Preview Before Sumbiting"
Post a Comment