From 107845f0764f76fb4b51171940775b487813a045 Mon Sep 17 00:00:00 2001 From: DJDAI Date: Wed, 1 Dec 2021 13:32:38 +0700 Subject: [PATCH 1/9] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B9=80=E0=B8=8A=E0=B8=B7?= =?UTF-8?q?=E0=B9=88=E0=B8=AD=E0=B8=A1=E0=B8=95=E0=B9=88=E0=B8=AD=E0=B8=90?= =?UTF-8?q?=E0=B8=B2=E0=B8=99=E0=B8=82=E0=B9=89=E0=B8=AD=E0=B8=A1=E0=B8=B9?= =?UTF-8?q?=E0=B8=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/config.php | 6 ++++++ app/connection.php | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 app/config.php create mode 100644 app/connection.php diff --git a/app/config.php b/app/config.php new file mode 100644 index 0000000..894db1c --- /dev/null +++ b/app/config.php @@ -0,0 +1,6 @@ + 'SET NAMES utf8mb4') + ); + $connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +} catch(PDOException $e) { + echo "The connection to the database failed: " . $e->getMessage(); + exit(); +} From da4124d166ce2f021ac7719a64ab71a11abc49fb Mon Sep 17 00:00:00 2001 From: DJDAI Date: Wed, 1 Dec 2021 14:00:14 +0700 Subject: [PATCH 2/9] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84?= =?UTF-8?q?=E0=B8=82=20frontend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ปรับจำนวนรูปอัพโหลดสูงสุดต่อรูป ส่งข้อมูลรูปไปบันทึกด้วย ajax --- index.html | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 2804fa0..68de66b 100644 --- a/index.html +++ b/index.html @@ -26,7 +26,7 @@
-
+
@@ -136,7 +136,7 @@ // Create image loader plugin var imagesloader = $('[data-type=imagesloader]').imagesloader({ - maxFiles: 4 + maxFiles: 16 , minSelect: 1 , imagesToLoad: auctionImages }); @@ -153,8 +153,21 @@ var il = imagesloader.data('format.imagesloader'); - if (il.CheckValidity()) - alert('Upload ' + files.length + ' files'); + if (il.CheckValidity()){ + $.ajax({ + url: 'save.php', + type: 'POST', + data: JSON.stringify(files), + success: function (response) { + response = $.parseJSON(response); + if(response.status == 'completed'){ + alert('Upload ' + files.length + ' files, Completed'); + } else { + alert('Upload failed'); + } + } + }) + } e.preventDefault(); e.stopPropagation(); From 4503405e1d456dd88ab3bb0a7134344974fea2c4 Mon Sep 17 00:00:00 2001 From: DJDAI Date: Wed, 1 Dec 2021 14:00:37 +0700 Subject: [PATCH 3/9] =?UTF-8?q?=E0=B8=AA=E0=B8=A3=E0=B9=89=E0=B8=B2?= =?UTF-8?q?=E0=B8=87=E0=B9=84=E0=B8=9F=E0=B8=A5=E0=B9=8C=E0=B8=AA=E0=B8=B3?= =?UTF-8?q?=E0=B8=AB=E0=B8=A3=E0=B8=B1=E0=B8=9A=E0=B8=9A=E0=B8=B1=E0=B8=99?= =?UTF-8?q?=E0=B8=97=E0=B8=B6=E0=B8=81=E0=B8=A3=E0=B8=B9=E0=B8=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- save.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 save.php diff --git a/save.php b/save.php new file mode 100644 index 0000000..16916db --- /dev/null +++ b/save.php @@ -0,0 +1,20 @@ + $val){ + // Set new name image file + $explode_filename = explode('.', $val->FileName); + $new_filename = current($explode_filename).'_'.date('YmdHis').'.'.end($explode_filename); + + // Upload file from Base64 + file_put_contents('img/upload/'.$new_filename, base64_decode($val->Base64)); + + // Insert image name to DB + +} +echo json_encode( array('status' => 'completed') ); \ No newline at end of file From 33acab7da25bb59469ade79b1ca2b02513c94ef1 Mon Sep 17 00:00:00 2001 From: Chutipon516 Date: Wed, 1 Dec 2021 14:42:18 +0700 Subject: [PATCH 4/9] Update save.php --- save.php | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/save.php b/save.php index 16916db..df0c629 100644 --- a/save.php +++ b/save.php @@ -6,6 +6,8 @@ $data = json_decode($json); +$i = 0; + foreach($data AS $key => $val){ // Set new name image file $explode_filename = explode('.', $val->FileName); @@ -14,7 +16,63 @@ // Upload file from Base64 file_put_contents('img/upload/'.$new_filename, base64_decode($val->Base64)); - // Insert image name to DB - + $arraydata["imagename"][$i] = $new_filename; + $i++; } +// Insert image name to DB +$insert = $connect->prepare( + "INSERT INTO ( + image1, + image3, + image4, + image5, + image6, + image7, + image8, + image9, + image10, + image11, + image12, + image13, + image14, + image15, + image16) + VALUES ( + :image1, + :image3, + :image4, + :image5, + :image6, + :image7, + :image8, + :image9, + :image10, + :image11, + :image12, + :image13, + :image14, + :image15, + :image16)" +); +$insert->execute( + array( + ":image1" => $arraydata["imagename"][0], + ":image2" => $arraydata["imagename"][1], + ":image3" => $arraydata["imagename"][2], + ":image4" => $arraydata["imagename"][3], + ":image5" => $arraydata["imagename"][4], + ":image6" => $arraydata["imagename"][5], + ":image7" => $arraydata["imagename"][6], + ":image8" => $arraydata["imagename"][7], + ":image9" => $arraydata["imagename"][8], + ":image10" => $arraydata["imagename"][9], + ":image11" => $arraydata["imagename"][10], + ":image12" => $arraydata["imagename"][11], + ":image13" => $arraydata["imagename"][12], + ":image14" => $arraydata["imagename"][13], + ":image15" => $arraydata["imagename"][14], + ":image16" => $arraydata["imagename"][15], + + ); +); echo json_encode( array('status' => 'completed') ); \ No newline at end of file From 88799bfe7cced2554645980fc979dec2daf667fd Mon Sep 17 00:00:00 2001 From: DJDAI Date: Wed, 1 Dec 2021 15:26:31 +0700 Subject: [PATCH 5/9] Update save.php --- save.php | 64 +++++++++++++++----------------------------------------- 1 file changed, 17 insertions(+), 47 deletions(-) diff --git a/save.php b/save.php index df0c629..1570069 100644 --- a/save.php +++ b/save.php @@ -6,54 +6,24 @@ $data = json_decode($json); -$i = 0; - -foreach($data AS $key => $val){ +for($i = 0; $i <= 15; $i++){ // Set new name image file - $explode_filename = explode('.', $val->FileName); - $new_filename = current($explode_filename).'_'.date('YmdHis').'.'.end($explode_filename); - - // Upload file from Base64 - file_put_contents('img/upload/'.$new_filename, base64_decode($val->Base64)); + if(!empty($data[$i]->FileName)){ + $explode_filename = explode('.', $data[$i]->FileName); + $new_filename = current($explode_filename).'_'.date('YmdHis').'.'.end($explode_filename); + + // Upload file from Base64 + file_put_contents('img/upload/'.$new_filename, base64_decode($data[$i]->Base64)); + } else { + $new_filename = NULL; + } - $arraydata["imagename"][$i] = $new_filename; - $i++; + $arraydata["imagename"][] = $new_filename; } + // Insert image name to DB -$insert = $connect->prepare( - "INSERT INTO ( - image1, - image3, - image4, - image5, - image6, - image7, - image8, - image9, - image10, - image11, - image12, - image13, - image14, - image15, - image16) - VALUES ( - :image1, - :image3, - :image4, - :image5, - :image6, - :image7, - :image8, - :image9, - :image10, - :image11, - :image12, - :image13, - :image14, - :image15, - :image16)" -); +$insert = $connect->prepare("INSERT INTO imageupload (image1,image2,image3,image4,image5,image6,image7,image8,image9,image10,image11,image12,image13,image14,image15,image16) + VALUES (:image1,:image2,:image3,:image4,:image5,:image6,:image7,:image8,:image9,:image10,:image11,:image12,:image13,:image14,:image15,:image16)"); $insert->execute( array( ":image1" => $arraydata["imagename"][0], @@ -71,8 +41,8 @@ ":image13" => $arraydata["imagename"][12], ":image14" => $arraydata["imagename"][13], ":image15" => $arraydata["imagename"][14], - ":image16" => $arraydata["imagename"][15], - - ); + ":image16" => $arraydata["imagename"][15] + ) ); + echo json_encode( array('status' => 'completed') ); \ No newline at end of file From 0cadd3648f572b623800e8f31f3018b6bdb488aa Mon Sep 17 00:00:00 2001 From: Yodsapon W <30995391+DJdai@users.noreply.github.com> Date: Thu, 2 Dec 2021 20:08:18 +0700 Subject: [PATCH 6/9] Delete save.php --- save.php | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) delete mode 100644 save.php diff --git a/save.php b/save.php deleted file mode 100644 index 1570069..0000000 --- a/save.php +++ /dev/null @@ -1,48 +0,0 @@ -FileName)){ - $explode_filename = explode('.', $data[$i]->FileName); - $new_filename = current($explode_filename).'_'.date('YmdHis').'.'.end($explode_filename); - - // Upload file from Base64 - file_put_contents('img/upload/'.$new_filename, base64_decode($data[$i]->Base64)); - } else { - $new_filename = NULL; - } - - $arraydata["imagename"][] = $new_filename; -} - -// Insert image name to DB -$insert = $connect->prepare("INSERT INTO imageupload (image1,image2,image3,image4,image5,image6,image7,image8,image9,image10,image11,image12,image13,image14,image15,image16) - VALUES (:image1,:image2,:image3,:image4,:image5,:image6,:image7,:image8,:image9,:image10,:image11,:image12,:image13,:image14,:image15,:image16)"); -$insert->execute( - array( - ":image1" => $arraydata["imagename"][0], - ":image2" => $arraydata["imagename"][1], - ":image3" => $arraydata["imagename"][2], - ":image4" => $arraydata["imagename"][3], - ":image5" => $arraydata["imagename"][4], - ":image6" => $arraydata["imagename"][5], - ":image7" => $arraydata["imagename"][6], - ":image8" => $arraydata["imagename"][7], - ":image9" => $arraydata["imagename"][8], - ":image10" => $arraydata["imagename"][9], - ":image11" => $arraydata["imagename"][10], - ":image12" => $arraydata["imagename"][11], - ":image13" => $arraydata["imagename"][12], - ":image14" => $arraydata["imagename"][13], - ":image15" => $arraydata["imagename"][14], - ":image16" => $arraydata["imagename"][15] - ) -); - -echo json_encode( array('status' => 'completed') ); \ No newline at end of file From 1598928b577a940a487dd6d517c643be4f89717b Mon Sep 17 00:00:00 2001 From: Yodsapon W <30995391+DJdai@users.noreply.github.com> Date: Thu, 2 Dec 2021 20:08:24 +0700 Subject: [PATCH 7/9] Delete index.html --- index.html | 181 ----------------------------------------------------- 1 file changed, 181 deletions(-) delete mode 100644 index.html diff --git a/index.html b/index.html deleted file mode 100644 index 68de66b..0000000 --- a/index.html +++ /dev/null @@ -1,181 +0,0 @@ - - - Format ImagesLoader - - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
- -
- -
-
- - -
- - -
- -
- - - - - -
-
-
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
- -
-
-
- -
- -
-
- - -
-
- - - -
-
- -
-
- -
- - - - - - From 18a85e9a24b28f55624948c5fa9c7abdebbbf7ba Mon Sep 17 00:00:00 2001 From: Yodsapon W <30995391+DJdai@users.noreply.github.com> Date: Thu, 2 Dec 2021 20:08:34 +0700 Subject: [PATCH 8/9] Delete connection.php --- app/connection.php | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 app/connection.php diff --git a/app/connection.php b/app/connection.php deleted file mode 100644 index 43a0ea7..0000000 --- a/app/connection.php +++ /dev/null @@ -1,26 +0,0 @@ - 'SET NAMES utf8mb4') - ); - $connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); -} catch(PDOException $e) { - echo "The connection to the database failed: " . $e->getMessage(); - exit(); -} From 403cb57bd8277661da779f0f9dc77e34cc9c660d Mon Sep 17 00:00:00 2001 From: Yodsapon W <30995391+DJdai@users.noreply.github.com> Date: Thu, 2 Dec 2021 20:08:42 +0700 Subject: [PATCH 9/9] Delete config.php --- app/config.php | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 app/config.php diff --git a/app/config.php b/app/config.php deleted file mode 100644 index 894db1c..0000000 --- a/app/config.php +++ /dev/null @@ -1,6 +0,0 @@ -