tinybox

Code for file upload software on up.concealed.world.
git clone git://git.concealed.world/tinybox
Log | Files | Refs | README | LICENSE

commit 37fa38bf4b4ed4303a088996e232758e1b0be44b
parent a38db7284ae3bf9784ced7a1832fd6d494393fc0
Author: Nixx <nixx@firemail.cc>
Date:   Thu, 17 Feb 2022 10:34:39 +0000

Check maxsize first

Diffstat:
Mindex.php | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/index.php b/index.php @@ -23,19 +23,20 @@ $protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERV $url = $protocol.$_SERVER['HTTP_HOST']; if($_FILES){ - $origname = $_FILES['upload']['name']; + if($_FILES['upload']['size'] > $maxsize){ + exit("ERR: Filesize too large.\n"); + } + $mtime = sprintf('%.6f', microtime(true)); $name = substr($mtime, 0, 10) . substr($mtime, 11); + + $origname = $_FILES['upload']['name']; $extpos = strripos($origname, '.'); if($extpos){ $ext = strtolower(substr($origname, $extpos + 1)); $name = $name.".".$ext; } - if($_FILES['upload']['size'] > $maxsize){ - exit("ERR: Filesize too large.\n"); - } - $tmpfile = $_FILES['upload']['tmp_name']; $isimage = getimagesize($tmpfile) ? true : false;