Created the file util
This commit is contained in:
parent
e814816465
commit
eebac9193e
12
client/src/common/utils/file.js
Normal file
12
client/src/common/utils/file.js
Normal file
@ -0,0 +1,12 @@
|
||||
export const uploadString = () => new Promise((resolve) => {
|
||||
const input = document.createElement("input");
|
||||
input.type = "file";
|
||||
input.accept = "text/plain";
|
||||
input.onchange = (e) => {
|
||||
const file = e.target.files[0];
|
||||
const reader = new FileReader();
|
||||
reader.onload = (e) => resolve(e.target.result);
|
||||
reader.readAsText(file);
|
||||
};
|
||||
input.click();
|
||||
});
|
Reference in New Issue
Block a user