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

Classic mode. File choice dialog pops up when upload button is clicked.

expand code expand code

Use nzFileList for uploaded files when page init.

expand code expand code

You lot tin can proceeds full control over filelist past configuring nzFileList. You tin can attain all kinds of customed functions. The post-obit shows two circumstances:

  1. limit the number of uploaded files.

  2. read from response and evidence file link.

expand code expand code

You can select and upload a whole directory.

expand code expand code

If uploaded file is a film, the thumbnail can be shown. IE8/9 do not back up local thumbnail show. Please use thumbUrl instead.

expand code expand code

Employ nzTransformFile for transform file earlier request such as add a watermark.

expand code expand code

Click to upload user's avatar, and validate size and format of picture with nzBeforeUpload.

The render value of function nzBeforeUpload can be a Observable to cheque asynchronously.

expand code expand code

After users upload picture, the thumbnail will be shown in listing. The upload button volition disappear when count meets limitation.

expand code expand code

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

You tin drag files to a specific expanse, to upload. Alternatively, you lot can also upload past selecting.

Nosotros tin can upload serveral files at once in modern browsers past giving the input the nzMultiple aspect.

expand code expand code

Upload files manually after nzBeforeUpload returns false.

expand code expand code

Customize local preview. Can handle with non-image format files such as video.

expand code expand code

Use Aliyun OSS upload case.

expand code expand code

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:                  {                  /* ... */                  }                  ,                  }                              
  1. 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                      }                                      
  2. fileList current list of files

  3. 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

    robinsonsual1938.blogspot.com

    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

    Iklan Atas Artikel

    Iklan Tengah Artikel 1

    Iklan Tengah Artikel 2

    Iklan Bawah Artikel