Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
$file = $_FILES["upload"]; $max = 5 * 1024 * 1024; // 5MB if ($file["size"] > $max) die("Too large"); $finfo = new finfo(FILEINFO_MIME_TYPE); $mime = $finfo->file($file["tmp_name"]); $allowed = ["image/jpeg", "image/png", "image/webp"]; if (!in_array($mime, $allowed, true)) die("Invalid type"); $name = bin2hex(random_bytes(16)) . ".jpg"; // random filename move_uploaded_file($file["tmp_name"], "/storage/uploads/" . $name);
Result
Open