Переглянути джерело

Build in Upload System

Somewhat people might think buildin things aren't not good. This might be the exceptional case.
tobychui 8 роки тому
батько
коміт
908d64d9e9
5 змінених файлів з 300 додано та 0 видалено
  1. 83 0
      upload/arozupload.php
  2. 3 0
      upload/decodename.php
  3. 109 0
      upload/index.php
  4. 0 0
      upload/tocas.min.css
  5. 105 0
      upload/uploads/index.php

+ 83 - 0
upload/arozupload.php

@@ -0,0 +1,83 @@
+<link rel="stylesheet" href="//cdn.rawgit.com/TeaMeow/TocasUI/master/dist/tocas.min.css">
+<html>
+	<div class="ts container">
+	<h1>IMUS Laboratory</h1>
+	<h2>ArOZ 系統管理之自動備份音樂庫</h2>
+    <h3>音樂上傳系統</h3>
+	</div>
+</html>
+<?php header('Content-type: text/html; charset=utf-8'); ?>
+<?php 
+
+
+if (!file_exists("uploads")){
+    mkdir("uploads");
+}
+if ($_POST['dirname']) {
+    $target_dir = "uploads/" . $_POST['dirname'] . '/';
+    if(!file_exists($target_dir)) {
+        mkdir("uploads/" . $_POST['dirname']);
+    }
+} else {
+    $target_dir = "uploads/";
+}
+for ($i = 0; $i < count($_FILES['fileToUpload']['name']); $i++) {
+	echo '<div class="ts container">';
+	echo '<div class="ts horizontal divider">' . $_FILES["fileToUpload"]["name"][$i] . '</div>';
+	echo '<div class="ts message">';
+	echo '<div class="header">Upload Name:<b> ' . $_FILES["fileToUpload"]["name"][$i] . '</b><br></div>';
+	$ext = end((explode(".", $_FILES["fileToUpload"]["name"][$i])));
+	$encodedname = bin2hex(str_replace('.' . $ext,"",$_FILES["fileToUpload"]["name"][$i]));
+	$rawfilename = hex2bin($encodedname) . $ext . '<br>';
+    $target_file = $target_dir . 'inith' . $encodedname . '.' .  $ext;
+	echo 'Storage Filename:<br>';
+	if (strlen ( $encodedname ) > 140){
+		echo substr($encodedname,0,100). '......' . substr($encodedname,-5) . '.' .  $ext . '<br>';
+	}else{
+		echo $encodedname . '.' .  $ext . '<br>';
+	}
+	
+	echo '</div>';
+    $uploadOk = 1;
+    if (file_exists($target_file)) {
+		echo '<div class="ts warning message">';
+        echo '<div class="header">' .$_FILES["fileToUpload"]["name"][$i] . " ALREADY EXISTS.<br> " . '</div>';
+		echo '</div>';
+        echo '<a class="ts primary button" href=' . "'" . $target_dir . "'" .  ">Upload Directory</a>";
+		echo '<a class="ts inverted button" href="../">Back to ArOZ</a><br>';
+		
+        $uploadOk = 0;
+    } 
+    if ($uploadOk == 0) {
+		echo '<div class="ts inverted negative message"><div class="header">';
+        echo $_FILES["fileToUpload"]["name"][$i] . " is not uploaded.<br>";
+		echo '</div></div><br>';
+    } else {
+        if (move_uploaded_file(iconv("utf-8","big5//TRANSLIT//IGNORE", $_FILES["fileToUpload"]["tmp_name"][$i]), iconv("utf-8","big5//TRANSLIT//IGNORE",$target_file))) {
+			echo '<div class="ts positive message">';
+			echo '<div class="header">';
+            echo "The file ".  $_FILES["fileToUpload"]["name"][$i]. ' has been uploaded.<br></div></div>
+            <a class="ts primary button"href=' . "'" . $target_dir . "'" .  ">Upload Directory</a>";
+			echo '<a class="ts inverted button" href="../">Back to ArOZ</a><br>';
+			//echo hex2bin($encodedname) . "<br>";
+        } else {
+			echo '<div class="ts negative message">';
+            echo '<div class="header">Sorry, there was an error when uploading your file' . $_FILES["fileToUpload"]["name"][$i] . '<br></div>';
+			echo '</div>';
+        }
+    }
+	echo '</div>';
+}
+    echo "<br>";
+	echo '</div>';
+	echo '<div class="ts horizontal divider">File Info</div>';
+	echo '<div class="ts container">';
+	var_dump($_FILES);
+	echo '</div>';
+
+?>
+<html>
+<div class="ts container">
+<p align="right"><img class="ts small image" src="http://123.203.74.171:8080/aroz/logo.png"></p>
+</div>
+</html>

+ 3 - 0
upload/decodename.php

@@ -0,0 +1,3 @@
+<?php
+echo hex2bin($_GET["filename"])
+?>

+ 109 - 0
upload/index.php

@@ -0,0 +1,109 @@
+<!DOCTYPE html>
+<html>
+<link rel="stylesheet" href="tocas.min.css">
+     <head>
+	 <meta charset="UTF-8">
+        <title>ArOZ Upload</title>
+        <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
+			
+    </head>
+	<body>
+    <div class="ts container">
+	<h1>IMUS Laboratory</h1>
+	<h2>ArOZ System Upload Interface</h2>
+	<div class="ts pointing secondary big menu">
+    <a class="item" href="../index.php">Index</a>
+    <a class="item" href="../music.php">Music</a>
+	<a class="item" href="../video.php">Video</a>
+	<a class="active item" href="../upload/">Upload</a>
+	<a class="item" href="uploads/">Upload Dir</a>
+</div>
+    <h3>Upload</h3>
+        
+        <form class="ts form" action="arozupload.php" method="POST" enctype="multipart/form-data">
+		<div class="ts jumbotron">
+		<h4 class="ts header"> Step 1 </h4>
+		<div class="sub header">Select file(s) to upload. </div><br>
+            <div class="form-group">
+                <div class="input-group">
+					
+                        <span class="ts primary basic button btn-file">
+                            Browse
+                            <input type="file" id="files" name="fileToUpload[]" id="fileToUpload" multiple>
+                        </span>
+					
+                </div>
+			</div>
+			</div>
+            <div class="ts jumbotron">
+			<h4 class="ts header"> Step 2 </h4>
+			<div class="sub header">Setup Directory Name(optional): </div>
+			<div class="field">
+			<select class="ts fluid basic dropdown" id="dirname" type="text" name='dirname'>
+				<option value=''>Files Directory</option>
+				<option value='music'>Music Bank</option>
+				<option value='video'>Video Bank</option>
+				
+			</select>
+        
+				</div>
+               <div class="sub header">Select Multiple Files with MOUSEDRAG, CTRL, SHIFT </div>
+            </div>
+            <input class="ts positive basic button" type="submit" value="Upload" name="submit">
+			<a class="ts negative basic button" href=".."> Cancel </a>
+
+        </form>
+        <div class="ts section divider"></div>
+		<p align="right"><img class="ts small image" src="../logo.png"></p>
+    </div>
+	
+	</div>
+</body>
+<style type="text/css">
+    .btn-file {
+  position: relative;
+  overflow: hidden;
+}
+.btn-file input[type=file] {
+  position: absolute;
+  top: 0;
+  right: 0;
+  min-width: 100%;
+  min-height: 100%;
+  font-size: 100px;
+  text-align: right;
+  filter: alpha(opacity=0);
+  opacity: 0;
+  background: red;
+  cursor: inherit;
+  display: block;
+}
+input[readonly] {
+  background-color: white !important;
+  cursor: text !important;
+}
+</style>
+<script type="text/javascript">
+    $(document).on('change', '.btn-file :file', function() {
+  var input = $(this),
+      numFiles = input.get(0).files ? input.get(0).files.length : 1,
+      label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
+  input.trigger('fileselect', [numFiles, label]);
+});
+
+$(document).ready( function() {
+    $('.btn-file :file').on('fileselect', function(event, numFiles, label) {
+        
+        var input = $(this).parents('.input-group').find(':text'),
+            log = numFiles > 1 ? numFiles + ' files selected' : label;
+        
+        if( input.length ) {
+            input.val(log);
+        } else {
+            //if( log ) alert(log);
+        }
+        
+    });
+});
+</script>
+</html>

Різницю між файлами не показано, бо вона завелика
+ 0 - 0
upload/tocas.min.css


Різницю між файлами не показано, бо вона завелика
+ 105 - 0
upload/uploads/index.php


Деякі файли не було показано, через те що забагато файлів було змінено