From 39d322b8d1f6c62305251ee48e0192999ea45f20 Mon Sep 17 00:00:00 2001 From: mariohs22 Date: Sat, 4 May 2019 00:19:38 +0300 Subject: [PATCH 1/3] Add files via upload --- index.html | 236 +++++++++++++++++++++++++++++++++++++++++++++++++++++ upload.php | 35 ++++++++ 2 files changed, 271 insertions(+) create mode 100644 index.html create mode 100644 upload.php diff --git a/index.html b/index.html new file mode 100644 index 0000000..1d7d50e --- /dev/null +++ b/index.html @@ -0,0 +1,236 @@ + + + + + + + ScanAppForWeb thumbnail example + + + + + +
+
+

ScanAppForWeb thumbnail example

+
+
+
+
+
No scanned images
+
+
+
+ + + +

This expample shows how to make preview scanned images, rotate images if necessary and upload images to the server.

+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/upload.php b/upload.php new file mode 100644 index 0000000..3163eea --- /dev/null +++ b/upload.php @@ -0,0 +1,35 @@ + 19000000){ + throw new RuntimeException('Exceeded filesize limit.'); + } + $finfo = new finfo(FILEINFO_MIME_TYPE); + if (false === $ext = array_search($finfo->file($_FILES['blob']['tmp_name']), array('jpg' => 'image/jpeg', 'png' => 'image/png'), true)){ + throw new RuntimeException('Bad image type.'); + } + if ($_FILES['blob']['error'] == UPLOAD_ERR_OK) + { + $_dir = ''; + $_temp_filename = bin2hex(random_bytes(5)).'.jpg'; + if (!move_uploaded_file($_FILES['blob']['tmp_name'], $_dir.$_temp_filename)){ + throw new RuntimeException('Error on saving image.'); + } + // update your project's database + // ... + // $file_id = $dbh->lastInsertId(); + $file_id = rand(); + echo json_encode( ['newname' => mb_strimwidth($_temp_filename, 0, 18, '...'), 'file_id' => $file_id] ); + } + exit; + } catch (RuntimeException $e) { + die($e->getMessage()); + } + break; +} \ No newline at end of file From d7c82d7f0830484cfb32486d5fcba9fdd88b2959 Mon Sep 17 00:00:00 2001 From: mariohs22 Date: Sat, 4 May 2019 00:20:49 +0300 Subject: [PATCH 2/3] Delete index.html --- index.html | 236 ----------------------------------------------------- 1 file changed, 236 deletions(-) delete mode 100644 index.html diff --git a/index.html b/index.html deleted file mode 100644 index 1d7d50e..0000000 --- a/index.html +++ /dev/null @@ -1,236 +0,0 @@ - - - - - - - ScanAppForWeb thumbnail example - - - - - -
-
-

ScanAppForWeb thumbnail example

-
-
-
-
-
No scanned images
-
-
-
- - - -

This expample shows how to make preview scanned images, rotate images if necessary and upload images to the server.

-
-
- -
-
-
- - \ No newline at end of file From cd4b7ecf30485a6f7747d815d123c68e63c66913 Mon Sep 17 00:00:00 2001 From: mariohs22 Date: Sat, 4 May 2019 00:21:00 +0300 Subject: [PATCH 3/3] Delete upload.php --- upload.php | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 upload.php diff --git a/upload.php b/upload.php deleted file mode 100644 index 3163eea..0000000 --- a/upload.php +++ /dev/null @@ -1,35 +0,0 @@ - 19000000){ - throw new RuntimeException('Exceeded filesize limit.'); - } - $finfo = new finfo(FILEINFO_MIME_TYPE); - if (false === $ext = array_search($finfo->file($_FILES['blob']['tmp_name']), array('jpg' => 'image/jpeg', 'png' => 'image/png'), true)){ - throw new RuntimeException('Bad image type.'); - } - if ($_FILES['blob']['error'] == UPLOAD_ERR_OK) - { - $_dir = ''; - $_temp_filename = bin2hex(random_bytes(5)).'.jpg'; - if (!move_uploaded_file($_FILES['blob']['tmp_name'], $_dir.$_temp_filename)){ - throw new RuntimeException('Error on saving image.'); - } - // update your project's database - // ... - // $file_id = $dbh->lastInsertId(); - $file_id = rand(); - echo json_encode( ['newname' => mb_strimwidth($_temp_filename, 0, 18, '...'), 'file_id' => $file_id] ); - } - exit; - } catch (RuntimeException $e) { - die($e->getMessage()); - } - break; -} \ No newline at end of file