summaryrefslogtreecommitdiff
path: root/forum/utils/filehandler.php
blob: dfe0c807b4d47087f2a1fbcf2e0b2eed5c7e76e0 (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
34
35
36
<?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'];
		if(filesize($_FILES['userfile']['tmp_name']) <= $FILE_MAX_SIZE) $files->newFile($_FILES['userfile']['tmp_name'], $name);
		else echo "File is too big " . sprintf("%.0f", filesize($_FILES['userfile']['tmp_name'])/1024).
					 "kb, max file size: " . sprintf("%.0f", $FILE_MAX_SIZE/1024) . "kb.";
	}
}

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>