arozupload.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <link rel="stylesheet" href="//cdn.rawgit.com/TeaMeow/TocasUI/master/dist/tocas.min.css">
  2. <html>
  3. <div class="ts container">
  4. <h1>IMUS Laboratory</h1>
  5. <h2>ArOZ 系統管理之自動備份音樂庫</h2>
  6. <h3>音樂上傳系統</h3>
  7. </div>
  8. </html>
  9. <?php header('Content-type: text/html; charset=utf-8'); ?>
  10. <?php
  11. if (!file_exists("uploads")){
  12. mkdir("uploads");
  13. }
  14. if ($_POST['dirname']) {
  15. $target_dir = "uploads/" . $_POST['dirname'] . '/';
  16. if(!file_exists($target_dir)) {
  17. mkdir("uploads/" . $_POST['dirname']);
  18. }
  19. } else {
  20. $target_dir = "uploads/";
  21. }
  22. for ($i = 0; $i < count($_FILES['fileToUpload']['name']); $i++) {
  23. echo '<div class="ts container">';
  24. echo '<div class="ts horizontal divider">' . $_FILES["fileToUpload"]["name"][$i] . '</div>';
  25. echo '<div class="ts message">';
  26. echo '<div class="header">Upload Name:<b> ' . $_FILES["fileToUpload"]["name"][$i] . '</b><br></div>';
  27. $ext = end((explode(".", $_FILES["fileToUpload"]["name"][$i])));
  28. $encodedname = bin2hex(str_replace('.' . $ext,"",$_FILES["fileToUpload"]["name"][$i]));
  29. $rawfilename = hex2bin($encodedname) . $ext . '<br>';
  30. $target_file = $target_dir . 'inith' . $encodedname . '.' . $ext;
  31. echo 'Storage Filename:<br>';
  32. if (strlen ( $encodedname ) > 140){
  33. echo substr($encodedname,0,100). '......' . substr($encodedname,-5) . '.' . $ext . '<br>';
  34. }else{
  35. echo $encodedname . '.' . $ext . '<br>';
  36. }
  37. echo '</div>';
  38. $uploadOk = 1;
  39. if (file_exists($target_file)) {
  40. echo '<div class="ts warning message">';
  41. echo '<div class="header">' .$_FILES["fileToUpload"]["name"][$i] . " ALREADY EXISTS.<br> " . '</div>';
  42. echo '</div>';
  43. echo '<a class="ts primary button" href=' . "'" . $target_dir . "'" . ">Upload Directory</a>";
  44. echo '<a class="ts inverted button" href="../">Back to ArOZ</a><br>';
  45. $uploadOk = 0;
  46. }
  47. if ($uploadOk == 0) {
  48. echo '<div class="ts inverted negative message"><div class="header">';
  49. echo $_FILES["fileToUpload"]["name"][$i] . " is not uploaded.<br>";
  50. echo '</div></div><br>';
  51. } else {
  52. if (move_uploaded_file(iconv("utf-8","big5//TRANSLIT//IGNORE", $_FILES["fileToUpload"]["tmp_name"][$i]), iconv("utf-8","big5//TRANSLIT//IGNORE",$target_file))) {
  53. echo '<div class="ts positive message">';
  54. echo '<div class="header">';
  55. echo "The file ". $_FILES["fileToUpload"]["name"][$i]. ' has been uploaded.<br></div></div>
  56. <a class="ts primary button"href=' . "'" . $target_dir . "'" . ">Upload Directory</a>";
  57. echo '<a class="ts inverted button" href="../">Back to ArOZ</a><br>';
  58. //echo hex2bin($encodedname) . "<br>";
  59. } else {
  60. echo '<div class="ts negative message">';
  61. echo '<div class="header">Sorry, there was an error when uploading your file' . $_FILES["fileToUpload"]["name"][$i] . '<br></div>';
  62. echo '</div>';
  63. }
  64. }
  65. echo '</div>';
  66. }
  67. echo "<br>";
  68. echo '</div>';
  69. echo '<div class="ts horizontal divider">File Info</div>';
  70. echo '<div class="ts container">';
  71. var_dump($_FILES);
  72. echo '</div>';
  73. ?>
  74. <html>
  75. <div class="ts container">
  76. <p align="right"><img class="ts small image" src="http://123.203.74.171:8080/aroz/logo.png"></p>
  77. </div>
  78. </html>