Skip to content

Commit dc73c0e

Browse files
committed
feat: add showOpenFilePicker method
1 parent 0d0ca2f commit dc73c0e

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ customRequest callback is passed an object with:
113113

114114
abort(file?: File) => void: abort the uploading file
115115

116+
showOpenFilePicker() => void: open file picker
117+
116118
## License
117119

118120
rc-upload is released under the MIT license.

src/AjaxUploader.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ class AjaxUploader extends Component<UploadProps> {
4141
this.reset();
4242
};
4343

44+
showOpenFilePicker = () => {
45+
this.fileInput?.click();
46+
};
47+
4448
onClick = (e: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>) => {
4549
const el = this.fileInput;
4650
if (!el) {

src/Upload.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ class Upload extends Component<UploadProps> {
2929
this.uploader.abort(file);
3030
}
3131

32+
showOpenFilePicker() {
33+
this.uploader.showOpenFilePicker();
34+
}
35+
3236
saveUploader = (node: AjaxUpload) => {
3337
this.uploader = node;
3438
};

0 commit comments

Comments
 (0)