From b08e28ac279c0199d7f828d05e6e346865579592 Mon Sep 17 00:00:00 2001 From: Tyler Schicke Date: Tue, 21 May 2019 19:44:27 -0400 Subject: Fixed image upload --- src/mobile/ImageUpload.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') 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) => { + 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) { -- cgit v1.2.3-70-g09d2