Skip to content

Commit

Permalink
feat: add showOpenFilePicker method
Browse files Browse the repository at this point in the history
  • Loading branch information
linxianxi committed Jun 2, 2023
1 parent 0d0ca2f commit dc73c0e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 4 additions & 0 deletions src/AjaxUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ class AjaxUploader extends Component<UploadProps> {
this.reset();
};

showOpenFilePicker = () => {
this.fileInput?.click();
};

onClick = (e: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>) => {
const el = this.fileInput;
if (!el) {
Expand Down
4 changes: 4 additions & 0 deletions src/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class Upload extends Component<UploadProps> {
this.uploader.abort(file);
}

showOpenFilePicker() {
this.uploader.showOpenFilePicker();
}

saveUploader = (node: AjaxUpload) => {
this.uploader = node;
};
Expand Down

0 comments on commit dc73c0e

Please sign in to comment.