summaryrefslogtreecommitdiff
path: root/forum/utils/filehandler.php
blob: 9cacb1c71cb1c55effd8d80d05145873957768f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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=filehandler&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>