summaryrefslogtreecommitdiff
path: root/forum/utils/filehandler.php
diff options
context:
space:
mode:
authordeva <deva>2008-10-04 10:38:03 +0000
committerdeva <deva>2008-10-04 10:38:03 +0000
commitcce5e7710295021b41d9aaecc503a60fb99256be (patch)
tree660235be91fb821e976c7ae62347eb368ce87524 /forum/utils/filehandler.php
Initial revision
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>