diff options
| author | Andrew Kim <andrewdkim@users.noreply.github.com> | 2019-03-17 19:07:17 -0400 |
|---|---|---|
| committer | Andrew Kim <andrewdkim@users.noreply.github.com> | 2019-03-17 19:07:17 -0400 |
| commit | 94baa241afd3a99b233ae6197b7e404951347413 (patch) | |
| tree | 3a7b996c099bd8e0c0ad0667b054ed4fa45fd95a /src | |
| parent | c1f88978266a007b1516295135d6959666a31894 (diff) | |
Updated ImageUpload
Diffstat (limited to 'src')
| -rw-r--r-- | src/mobile/ImageUpload.tsx | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/mobile/ImageUpload.tsx b/src/mobile/ImageUpload.tsx index 6e15b0802..9a9ea0693 100644 --- a/src/mobile/ImageUpload.tsx +++ b/src/mobile/ImageUpload.tsx @@ -1,6 +1,8 @@ import * as ReactDOM from 'react-dom'; import React = require('react'); import "./ImageUpload.scss" +import { action, runInAction } from "mobx"; + @@ -11,11 +13,31 @@ const onPointerDown = (e: React.TouchEvent) => { } } +const onFileLoad = (file:any) => { + let img = new Image(); + let imgPrev = document.getElementById("img_preview") + if (imgPrev){ + let files = file.target.files; + if (files.length != 0){ + console.log(files[0]); + console.log(window.location.origin) + const upload = window.location.origin + "/upload"; + let formData = new FormData(); + formData.append("file", files[0]); + console.log(window.location.origin + file[0]) + + //imgPrev.setAttribute("src", window.location.origin + files[0].name) + } + } + + +} + ReactDOM.render(( <div className = "imgupload_cont"> <button className = "button_file" onTouchStart = {onPointerDown}> Open Image </button> - <input type= "file" accept = "image/*" capture="camera" className = "input_file" id = "input_image_file"></input> - + <input type= "file" accept = "image/*" capture="camera" onChange = {onFileLoad} className = "input_file" id = "input_image_file"></input> + <img id = "img_preview" src = ""></img> </div>), document.getElementById('root') );
\ No newline at end of file |
