aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Schicke <tyler_schicke@brown.edu>2019-05-21 19:44:27 -0400
committerTyler Schicke <tyler_schicke@brown.edu>2019-05-21 19:44:27 -0400
commitb08e28ac279c0199d7f828d05e6e346865579592 (patch)
tree65d58ec2d203210b5fce67a4062be3ef77587d1e
parent1f2b6f2ff438be8ea914a431b0efa8198ec23d96 (diff)
Fixed image upload
-rw-r--r--src/mobile/ImageUpload.tsx11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/mobile/ImageUpload.tsx b/src/mobile/ImageUpload.tsx
index 1f9e160ce..690937339 100644
--- a/src/mobile/ImageUpload.tsx
+++ b/src/mobile/ImageUpload.tsx
@@ -20,12 +20,15 @@ import { List } from '../new_fields/List';
// }
// }
-const onFileLoad = async (file: any) => {
+const onFileLoad = async (file: React.ChangeEvent<HTMLInputElement>) => {
+ file.persist();
+ await Docs.initProtos();
let imgPrev = document.getElementById("img_preview");
if (imgPrev) {
- let files: File[] = file.target.files;
- if (files.length !== 0) {
+ let files: FileList | null = file.target.files;
+ if (files && files.length !== 0) {
console.log(files[0]);
+ const name = files[0].name;
let formData = new FormData();
formData.append("file", files[0]);
@@ -37,7 +40,7 @@ const onFileLoad = async (file: any) => {
const json = await res.json();
json.map(async (file: any) => {
let path = window.location.origin + file;
- var doc = Docs.ImageDocument(path, { nativeWidth: 200, width: 200 });
+ var doc = Docs.ImageDocument(path, { nativeWidth: 200, width: 200, title: name });
const res = await rp.get(DocServer.prepend(RouteStore.getUserDocumentId));
if (!res) {