img.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <html>
  2. <meta name="viewport" content="width=device-width, initial-scale=1">
  3. <head>
  4. <title>QuickSend Image</title>
  5. <link rel="stylesheet" href="tocas.css">
  6. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  7. <script type="text/javascript" src="jquery.qrcode.min.js"></script>
  8. </head>
  9. <body>
  10. <div class="ts inverted heading fluid slate" style="background-color:#2c2835;color:white;">
  11. <span class="large header">Quick Send System</span>
  12. <span class="description">Send data between mobile and laptops.<br> Powered by IMUS Laboratory</span>
  13. <div class="ts bottom attached tabbed menu" style="color:white;">
  14. <a class="item" href="index.php" style="color:#9d9ca3;">Send</a>
  15. <a class="item" href="rx.php" style="color:#9d9ca3;">Receive</a>
  16. <a class="active item" href="img.php">Image</a>
  17. <a class="item" href="file.php" style="color:#9d9ca3;">Files</a>
  18. </div>
  19. </div>
  20. <br><br>
  21. <div class="ts container">
  22. <div class="ts stackable centered grid">
  23. <div class="six wide column" align="center" style="overflow:hidden;">
  24. <div class="ts fluid steps">
  25. <div class="step">
  26. <div class="content">
  27. <div class="title">Step 1</div>
  28. <div class="description">Select your image to send</div>
  29. </div>
  30. </div>
  31. </div>
  32. <input class="ts button" id="inp" type='file' style="width:100%;"><br>
  33. <button class="ts basic fluid negative button" onclick="clearselection()">Clear</button>
  34. <div class="ts narrow container" style="">
  35. <p id="b64"></p>
  36. <img id="img" src='img/noimg.png' height="150">
  37. </div>
  38. </div>
  39. <div class="five wide column" align="center">
  40. <div class="ts fluid steps">
  41. <div class="step">
  42. <div class="content">
  43. <div class="title">Step 2</div>
  44. <div class="description">Generate the sender QR Code</div>
  45. </div>
  46. </div>
  47. </div>
  48. <div class="ts inverted segment">
  49. <div class="ts tiny inverted statistics">
  50. <div class="statistic">
  51. <div class="value" id="width">N/A</div>
  52. <div class="label">Image Width</div>
  53. </div>
  54. <div class="statistic">
  55. <div class="value" id="height">N/A</div>
  56. <div class="label">Image Height</div>
  57. </div>
  58. <div class="statistic">
  59. <div class="value" id="size">N/A</div>
  60. <div class="label">Storage Size</div>
  61. </div>
  62. </div>
  63. </div>
  64. <button class="ts basic fluid button" onclick="senddata()">Generate QR Code</button>
  65. </div>
  66. <div class="five wide column" align="center">
  67. <div class="ts fluid steps">
  68. <div class="step">
  69. <div class="content">
  70. <div class="title">Step 3</div>
  71. <div class="description">Use the QR Code to receive the image.</div>
  72. </div>
  73. </div>
  74. </div>
  75. <div id="output"></div>
  76. <div class="ts small statistic">
  77. <div class="label">QuickSend ID</div>
  78. <div class="value" id="sid"><?php
  79. $max = 0;
  80. foreach (new DirectoryIterator('Memo/') as $fileInfo) {
  81. if ($fileInfo->isDot()) continue;
  82. $current = pathinfo($fileInfo->getFilename())['filename'];
  83. if (!is_numeric($current)) continue;
  84. if ($current > $max) $max = $current;
  85. }
  86. echo $max+1;
  87. ?></div>
  88. </div>
  89. </div>
  90. </div>
  91. <div class="ts fluid input" style="display:none;">
  92. <div class="ts input" style="width: 100%;height:250px">
  93. <textarea id="base64" placeholder="Encoded Base64 Content..."></textarea>
  94. </div>
  95. </div>
  96. <div class="ts segment">
  97. <div class="ts grid" align="center">
  98. <div class="six wide column">
  99. </div>
  100. <div class="ten wide column">
  101. </div>
  102. </div>
  103. </div>
  104. <br><br><br><br><br><br>
  105. <div style="position: fixed;
  106. z-index: 100;
  107. bottom: 0;
  108. left: 0;
  109. width: 100%;
  110. background-color:#2c2835;
  111. color:white;">
  112. <div class="ts container">
  113. <img class="ts tiny right floated image" src="img/cube.png"></img>
  114. </div>
  115. <div align="left" class="ts container">
  116. <br>
  117. CopyRight IMUS Laboratory 2021, All right reserved.
  118. </div>
  119. </div>
  120. <script>
  121. function clearselection(){
  122. $("#base64").val('');
  123. document.getElementById("img").src = 'img/noimg.png';
  124. $("#inp").val("");
  125. $("#width").text("Null");
  126. $("#height").text("Null");
  127. $("#size").text("Null");
  128. }
  129. function bytesToSize(bytes) {
  130. var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
  131. if (bytes == 0) return '0 Byte';
  132. var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
  133. return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
  134. };
  135. function readFile() {
  136. if (this.files && this.files[0]) {
  137. var FR= new FileReader();
  138. FR.addEventListener("load", function(e) {
  139. document.getElementById("img").src = e.target.result;
  140. $("#base64").val(e.target.result);
  141. var i = new Image();
  142. i.src = document.getElementById("img").src;
  143. i.onload = function(){
  144. console.log(i.width);
  145. $("#width").text(i.width + "px");
  146. console.log(i.height);
  147. $("#height").text(i.height+ "px");
  148. $("#size").text(bytesToSize(encodeURI(e.target.result).split(/%..|./).length - 1));
  149. }
  150. });
  151. FR.readAsDataURL( this.files[0] );
  152. }
  153. }
  154. jQuery(function(){
  155. jQuery('#output').qrcode("Hello World");
  156. })
  157. function senddata(){
  158. textarea = $('#base64').val();
  159. if (textarea != ""){
  160. $.ajax({
  161. type: "POST",
  162. url: "StickMemo.php",
  163. data:{ content: textarea },
  164. success: function(data){
  165. //alert(data);
  166. $("#output").empty();
  167. jQuery('#output').qrcode("http://imuslab.com/qs/display.php?id=" + data);
  168. $("#sid").html(data);
  169. }
  170. })
  171. }}
  172. document.getElementById("inp").addEventListener("change", readFile);
  173. </script>
  174. </body>
  175. </html>