diff options
Diffstat (limited to 'upload_file.php')
-rw-r--r-- | upload_file.php | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/upload_file.php b/upload_file.php new file mode 100644 index 0000000..09f2bd7 --- /dev/null +++ b/upload_file.php @@ -0,0 +1,64 @@ +<?php include('config.php'); ?> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> + +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> +<title>Upload result</title> +</head> +<body> +<p> +<?php +function size_readable($size, $max = null, $system = 'si', $retstring = '%01.2f %s') { + // Pick units + $systems['si']['prefix'] = array('B', 'K', 'MB', 'GB', 'TB', 'PB'); + $systems['si']['size'] = 1000; + $systems['bi']['prefix'] = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB'); + $systems['bi']['size'] = 1024; + $sys = isset($systems[$system]) ? $systems[$system] : $systems['si']; + + // Max unit to display + $depth = count($sys['prefix']) - 1; + if ($max && false !== $d = array_search($max, $sys['prefix'])) { + $depth = $d; + } + + // Loop + $i = 0; + while ($size >= $sys['size'] && $i < $depth) { + $size /= $sys['size']; + $i++; + } + + return sprintf($retstring, $size, $sys['prefix'][$i]); +} + + { + if ($_FILES["file"]["error"] > 0) + { + echo "Return Code: " . $_FILES["file"]["error"] . "<br>"; + } + else + { + if (file_exists($_FILES["file"]["name"])) + { + echo "Error: " . $_FILES["file"]["name"] . " already exists. "; + } + else + { + move_uploaded_file($_FILES["file"]["tmp_name"], + "./" . $_FILES["file"]["name"]); + echo "Uploaded: " . $_FILES["file"]["name"] . "<br>"; + $fileurl = "$url" . $_FILES["file"]["name"]; + echo "URL: <a href=\"$fileurl\">$fileurl</a><br>"; + echo "Size: " . size_readable($_FILES["file"]["size"], null, "bi"); + } + } + } +?> +</p> +<p> +<a href="<?php echo $url; ?>">Back to index</a> +</p> +</body> +</html> |