diff --git a/README.md b/README.md index 74906767..67be8ac4 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,8 @@ customRequest callback is passed an object with: abort(file?: File) => void: abort the uploading file +showOpenFilePicker() => void: open file picker + ## License rc-upload is released under the MIT license. diff --git a/src/AjaxUploader.tsx b/src/AjaxUploader.tsx index caa7b7d1..ae028335 100644 --- a/src/AjaxUploader.tsx +++ b/src/AjaxUploader.tsx @@ -41,6 +41,10 @@ class AjaxUploader extends Component { this.reset(); }; + showOpenFilePicker = () => { + this.fileInput?.click(); + }; + onClick = (e: React.MouseEvent | React.KeyboardEvent) => { const el = this.fileInput; if (!el) { diff --git a/src/Upload.tsx b/src/Upload.tsx index 548aca17..9ac9b05a 100644 --- a/src/Upload.tsx +++ b/src/Upload.tsx @@ -29,6 +29,10 @@ class Upload extends Component { this.uploader.abort(file); } + showOpenFilePicker() { + this.uploader.showOpenFilePicker(); + } + saveUploader = (node: AjaxUpload) => { this.uploader = node; };