summaryrefslogtreecommitdiff
path: root/forum/utils/filehandler.php
diff options
context:
space:
mode:
Diffstat (limited to 'forum/utils/filehandler.php')
-rw-r--r--forum/utils/filehandler.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/forum/utils/filehandler.php b/forum/utils/filehandler.php
new file mode 100644
index 0000000..231ddd6
--- /dev/null
+++ b/forum/utils/filehandler.php
@@ -0,0 +1,33 @@
+<?php
+include_once($UTIL_DIR . "/files.php");
+
+$files = new Files($DATA_DIR . "/files.xml");
+
+if($task == "upload") {
+ if(is_uploaded_file($_FILES['userfile']['tmp_name'])) {
+ $name = $filename;
+ if(!$filename) $name = $_FILES['userfile']['name'];
+ $files->newFile($_FILES['userfile']['tmp_name'], $name);
+ }
+}
+
+if($task == "delete" && $fid) {
+ $files->deleteFile($fid);
+}
+
+$files->show();
+
+
+?>
+<form enctype="multipart/form-data" action="?mode=files&amp;task=upload" method="post">
+ <p>
+ File: <input name="userfile" type="file">
+ </p>
+ <p>
+ Use alternative filename (leave empty to use original filename):
+ <input name="filename" value="<?php echo $description ?>"/>
+ </p>
+ <p>
+ <button type="submit">Add file</button>
+ </p>
+</form>