diff options
author | Luke Bratch <luke@bratch.co.uk> | 2015-11-22 21:56:53 +0000 |
---|---|---|
committer | Luke Bratch <luke@bratch.co.uk> | 2015-11-22 21:56:53 +0000 |
commit | 2dafdedfe29aee7ed19d141bbe0953e94b4a499b (patch) | |
tree | 5727aa8961128ca5a478250a86c9e1dd07108490 /upload_file.php | |
parent | d0de376dd93c4f8d308f023e6a388628b755b9d8 (diff) |
Various code cleanups
Diffstat (limited to 'upload_file.php')
-rw-r--r-- | upload_file.php | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/upload_file.php b/upload_file.php index a1b218e..890078a 100644 --- a/upload_file.php +++ b/upload_file.php @@ -1,4 +1,4 @@ -<?php include('config.php'); ?> +<?php include("config.php"); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> @@ -9,7 +9,7 @@ <body> <p> <?php -function size_readable($size, $max = null, $system = 'si', $retstring = '%01.2f %s') { +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; @@ -40,29 +40,20 @@ if (isset($_SERVER['HTTPS'])) { $url = preg_replace("/^https:\/\//", "http://", $url); } - { - 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"); - } - } +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> |