From eebac9193e6f4dcd84b25a4c50567e30ab2d4e2d Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Tue, 30 May 2023 23:16:40 +0200 Subject: [PATCH] Created the file util --- client/src/common/utils/file.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 client/src/common/utils/file.js diff --git a/client/src/common/utils/file.js b/client/src/common/utils/file.js new file mode 100644 index 0000000..b29c72c --- /dev/null +++ b/client/src/common/utils/file.js @@ -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(); +}); \ No newline at end of file