This commit has been accessed 703 times via Git panel.
commit 2e27c12f5c88e76d3a7f98d3674c3892351662d0
tree b9364de3878ed68ad68cb7b6c259f92c69e7d8d3
parent 4451d7bb68239ec2f1d3bf3b4a8f87fc1613487d
author Engels Antonio <engels@kartero.org> 1370213733 +0800
committer Engels Antonio <engels@kartero.org> 1370213733 +0800
Add multiple file upload support
diff --git a/filedrop.php b/filedrop.php
index aea3d9a..337a331 100644
--- a/filedrop.php
+++ b/filedrop.php
@@ -8,37 +8,40 @@ if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset
$filedrop_box = $_SESSION['filedrop_dir'];
-if (isset($_FILES['filedrop_obj']) and !empty($_FILES['filedrop_obj'])) {
-
- if (is_uploaded_file($_FILES['filedrop_obj']['tmp_name'])) {
-
- if ($_FILES['filedrop_obj']['size'] <= $max_file_size) {
-
- $filedrop_nom = str_replace(" ", "_", $_FILES['filedrop_obj']['name']);
- $filedrop_nom = preg_replace("/[^a-zA-Z0-9.\-_]/u", "", $filedrop_nom);
-
- if (!file_exists("attach/i/$fileUsr/$filedrop_box")) {
- mkdir("attach/i/$fileUsr/$filedrop_box",0700,1);
- }
-
- if (!file_exists("attach/i/$fileUsr/$filedrop_box/$filedrop_nom")) {
-
- $res = copy($_FILES['filedrop_obj']['tmp_name'], "attach/i/$fileUsr/$filedrop_box/$filedrop_nom");
- unlink($_FILES['filedrop_obj']['tmp_name']);
- //echo "<script>alert(\"{$_FILES['filedrop_obj']['name']} saved as $filedrop_nom\");</script>";
+if (isset($_FILES['filedrop_obj']) and !empty($_FILES['filedrop_obj'])) {
+
+ for ($i=0; $i<count($_FILES['filedrop_obj']['name']); $i++) {
+
+ if (is_uploaded_file($_FILES['filedrop_obj']['tmp_name'][$i])) {
+
+ if ($_FILES['filedrop_obj']['size'][$i] <= $max_file_size) {
+
+ $filedrop_nom = str_replace(" ", "_", $_FILES['filedrop_obj']['name'][$i]);
+ $filedrop_nom = preg_replace("/[^a-zA-Z0-9.\-_]/u", "", $filedrop_nom);
+
+ if (!file_exists("attach/i/$fileUsr/$filedrop_box")) {
+ mkdir("attach/i/$fileUsr/$filedrop_box",0700,1);
+ }
+
+ if (!file_exists("attach/i/$fileUsr/$filedrop_box/$filedrop_nom")) {
+
+ $res = copy($_FILES['filedrop_obj']['tmp_name'][$i], "attach/i/$fileUsr/$filedrop_box/$filedrop_nom");
+ unlink($_FILES['filedrop_obj']['tmp_name'][$i]);
+ //echo "<script>alert(\"{$_FILES['filedrop_obj']['name'][$i]} saved as $filedrop_nom\");</script>";
+ }
+ else {
+ unlink($_FILES['filedrop_obj']['tmp_name'][$i]);
+ }
}
else {
- unlink($_FILES['filedrop_obj']['tmp_name']);
+ unlink($_FILES['filedrop_obj']['tmp_name'][$i]);
+ //echo "<script>alert(\"Failed to save {$_FILES['filedrop_obj']['name'][$i]} because it is too big.\");</script>";
}
}
else {
- unlink($_FILES['filedrop_obj']['tmp_name']);
- //echo "<script>alert(\"Failed to save {$_FILES['filedrop_obj']['name']} because it is too big.\");</script>";
+ unlink($_FILES['filedrop_obj']['tmp_name'][$i]);
}
}
- else {
- unlink($_FILES['filedrop_obj']['tmp_name']);
- }
}
if (file_exists("attach/i/$fileUsr/$filedrop_box")) {
diff --git a/ics2.php b/ics2.php
index 5c244a3..d3c0a7d 100644
--- a/ics2.php
+++ b/ics2.php
@@ -9,6 +9,7 @@ if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset
function ics2array($file) {
$data = file_get_contents($file);
+ $data = quoted_printable_decode($data);
$data = str_replace(array(
"\r\n ",
"\n ",
diff --git a/post.php b/post.php
index d2e947c..89edc41 100644
--- a/post.php
+++ b/post.php
@@ -85,7 +85,7 @@ if (isset($_POST['new']) and !empty($_POST['new']) and is_numeric($_POST['new'])
<tr><td>
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>">
<input type="hidden" name="filedrop_box" value="<?php echo $filedrop_box; ?>">
-<input type="file" name="filedrop_obj">
+<input type="file" name="filedrop_obj[]" multiple>
<input type="submit" name="filedrop_submit" value="Upload">
</td>
diff --git a/send.php b/send.php
index 2ab8324..474ea5f 100644
--- a/send.php
+++ b/send.php
@@ -288,10 +288,10 @@ if ($_POST['rep'] != 4) {
<?php
if ($_POST['rep'] == 4) {
- echo "<input type=\"file\" name=\"filedrop_obj\" disabled>";
+ echo "<input type=\"file\" name=\"filedrop_obj[]\" disabled>";
}
else {
- echo "<input type=\"file\" name=\"filedrop_obj\">";
+ echo "<input type=\"file\" name=\"filedrop_obj[]\" multiple>";
}
?>
tree b9364de3878ed68ad68cb7b6c259f92c69e7d8d3
parent 4451d7bb68239ec2f1d3bf3b4a8f87fc1613487d
author Engels Antonio <engels@kartero.org> 1370213733 +0800
committer Engels Antonio <engels@kartero.org> 1370213733 +0800
Add multiple file upload support
diff --git a/filedrop.php b/filedrop.php
index aea3d9a..337a331 100644
--- a/filedrop.php
+++ b/filedrop.php
@@ -8,37 +8,40 @@ if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset
$filedrop_box = $_SESSION['filedrop_dir'];
-if (isset($_FILES['filedrop_obj']) and !empty($_FILES['filedrop_obj'])) {
-
- if (is_uploaded_file($_FILES['filedrop_obj']['tmp_name'])) {
-
- if ($_FILES['filedrop_obj']['size'] <= $max_file_size) {
-
- $filedrop_nom = str_replace(" ", "_", $_FILES['filedrop_obj']['name']);
- $filedrop_nom = preg_replace("/[^a-zA-Z0-9.\-_]/u", "", $filedrop_nom);
-
- if (!file_exists("attach/i/$fileUsr/$filedrop_box")) {
- mkdir("attach/i/$fileUsr/$filedrop_box",0700,1);
- }
-
- if (!file_exists("attach/i/$fileUsr/$filedrop_box/$filedrop_nom")) {
-
- $res = copy($_FILES['filedrop_obj']['tmp_name'], "attach/i/$fileUsr/$filedrop_box/$filedrop_nom");
- unlink($_FILES['filedrop_obj']['tmp_name']);
- //echo "<script>alert(\"{$_FILES['filedrop_obj']['name']} saved as $filedrop_nom\");</script>";
+if (isset($_FILES['filedrop_obj']) and !empty($_FILES['filedrop_obj'])) {
+
+ for ($i=0; $i<count($_FILES['filedrop_obj']['name']); $i++) {
+
+ if (is_uploaded_file($_FILES['filedrop_obj']['tmp_name'][$i])) {
+
+ if ($_FILES['filedrop_obj']['size'][$i] <= $max_file_size) {
+
+ $filedrop_nom = str_replace(" ", "_", $_FILES['filedrop_obj']['name'][$i]);
+ $filedrop_nom = preg_replace("/[^a-zA-Z0-9.\-_]/u", "", $filedrop_nom);
+
+ if (!file_exists("attach/i/$fileUsr/$filedrop_box")) {
+ mkdir("attach/i/$fileUsr/$filedrop_box",0700,1);
+ }
+
+ if (!file_exists("attach/i/$fileUsr/$filedrop_box/$filedrop_nom")) {
+
+ $res = copy($_FILES['filedrop_obj']['tmp_name'][$i], "attach/i/$fileUsr/$filedrop_box/$filedrop_nom");
+ unlink($_FILES['filedrop_obj']['tmp_name'][$i]);
+ //echo "<script>alert(\"{$_FILES['filedrop_obj']['name'][$i]} saved as $filedrop_nom\");</script>";
+ }
+ else {
+ unlink($_FILES['filedrop_obj']['tmp_name'][$i]);
+ }
}
else {
- unlink($_FILES['filedrop_obj']['tmp_name']);
+ unlink($_FILES['filedrop_obj']['tmp_name'][$i]);
+ //echo "<script>alert(\"Failed to save {$_FILES['filedrop_obj']['name'][$i]} because it is too big.\");</script>";
}
}
else {
- unlink($_FILES['filedrop_obj']['tmp_name']);
- //echo "<script>alert(\"Failed to save {$_FILES['filedrop_obj']['name']} because it is too big.\");</script>";
+ unlink($_FILES['filedrop_obj']['tmp_name'][$i]);
}
}
- else {
- unlink($_FILES['filedrop_obj']['tmp_name']);
- }
}
if (file_exists("attach/i/$fileUsr/$filedrop_box")) {
diff --git a/ics2.php b/ics2.php
index 5c244a3..d3c0a7d 100644
--- a/ics2.php
+++ b/ics2.php
@@ -9,6 +9,7 @@ if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset
function ics2array($file) {
$data = file_get_contents($file);
+ $data = quoted_printable_decode($data);
$data = str_replace(array(
"\r\n ",
"\n ",
diff --git a/post.php b/post.php
index d2e947c..89edc41 100644
--- a/post.php
+++ b/post.php
@@ -85,7 +85,7 @@ if (isset($_POST['new']) and !empty($_POST['new']) and is_numeric($_POST['new'])
<tr><td>
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>">
<input type="hidden" name="filedrop_box" value="<?php echo $filedrop_box; ?>">
-<input type="file" name="filedrop_obj">
+<input type="file" name="filedrop_obj[]" multiple>
<input type="submit" name="filedrop_submit" value="Upload">
</td>
diff --git a/send.php b/send.php
index 2ab8324..474ea5f 100644
--- a/send.php
+++ b/send.php
@@ -288,10 +288,10 @@ if ($_POST['rep'] != 4) {
<?php
if ($_POST['rep'] == 4) {
- echo "<input type=\"file\" name=\"filedrop_obj\" disabled>";
+ echo "<input type=\"file\" name=\"filedrop_obj[]\" disabled>";
}
else {
- echo "<input type=\"file\" name=\"filedrop_obj\">";
+ echo "<input type=\"file\" name=\"filedrop_obj[]\" multiple>";
}
?>