Limit each image to 1 MB.
UPLOAD_MAX_MB changes the limit, and UPLOAD_MAX_MB=none removes it.
This commit is contained in:
@@ -206,10 +206,18 @@ function validate_data() {
|
||||
$validate['story'] = "You've tried to remove an image without replacing it with text.";
|
||||
}
|
||||
|
||||
$upload_max = upload_max_bytes();
|
||||
$too_large = htmlspecialchars((string)($_FILES['upload']['name'] ?? '')) .
|
||||
($upload_max === NULL ? ' is larger than the server accepts.' : ' is larger than '.upload_max_mb().' MB.') .
|
||||
' Please choose a smaller image.';
|
||||
// 0 == no error; 4 == no file; all others are errors.
|
||||
if ($upload_error > 0 &&
|
||||
if ($upload_error === UPLOAD_ERR_INI_SIZE || $upload_error === UPLOAD_ERR_FORM_SIZE) {
|
||||
$validate['upload'] = $too_large;
|
||||
} else if ($upload_error > 0 &&
|
||||
$upload_error !== 4) {
|
||||
$validate['upload'] = 'There was an error uploading the file ('.$upload_error.')';
|
||||
} else if ($upload_tmp && $upload_max !== NULL && (int)@filesize($upload_tmp) > $upload_max) {
|
||||
$validate['upload'] = $too_large;
|
||||
} else if ($upload_tmp) {
|
||||
$upload = getimagesize($upload_tmp);
|
||||
if (!$upload)
|
||||
|
||||
Reference in New Issue
Block a user