Maximum image dimensions
This commit is contained in:
parent
690f206a63
commit
8849f5a2db
@ -41,6 +41,7 @@
|
|||||||
define('ERROR_FILEEXT', 'Unsupported image format.');
|
define('ERROR_FILEEXT', 'Unsupported image format.');
|
||||||
define('ERR_INVALIDIMG','Invalid image.');
|
define('ERR_INVALIDIMG','Invalid image.');
|
||||||
define('ERR_FILSIZE', 'The file was too large.');
|
define('ERR_FILSIZE', 'The file was too large.');
|
||||||
|
define('ERR_MAXSIZE', 'The file was too big.');
|
||||||
|
|
||||||
// For resizing, max values
|
// For resizing, max values
|
||||||
define('THUMB_WIDTH', 200);
|
define('THUMB_WIDTH', 200);
|
||||||
@ -48,6 +49,9 @@
|
|||||||
|
|
||||||
// Maximum image upload size in bytes
|
// Maximum image upload size in bytes
|
||||||
define('MAX_FILESIZE', 1048576); // 10MB
|
define('MAX_FILESIZE', 1048576); // 10MB
|
||||||
|
// Maximum image dimensions
|
||||||
|
define('MAX_WIDTH', 1000);
|
||||||
|
define('MAX_HEIGHT', MAX_WIDTH);
|
||||||
|
|
||||||
define('DIR_IMG', 'src/');
|
define('DIR_IMG', 'src/');
|
||||||
define('DIR_THUMB', 'thumb/');
|
define('DIR_THUMB', 'thumb/');
|
||||||
|
5
post.php
5
post.php
@ -121,6 +121,11 @@
|
|||||||
error(ERR_INVALIDIMG);
|
error(ERR_INVALIDIMG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($post['width'] > MAX_WIDTH || $post['height'] > MAX_HEIGHT) {
|
||||||
|
unlink($post['file']);
|
||||||
|
error(ERR_MAXSIZE);
|
||||||
|
}
|
||||||
|
|
||||||
$post['filesize'] = filesize($post['file']);
|
$post['filesize'] = filesize($post['file']);
|
||||||
$thumb = resize($post['extension'], $post['file'], $post['thumb'], THUMB_WIDTH, THUMB_HEIGHT);
|
$thumb = resize($post['extension'], $post['file'], $post['thumb'], THUMB_WIDTH, THUMB_HEIGHT);
|
||||||
$post['thumbwidth'] = $thumb['width'];
|
$post['thumbwidth'] = $thumb['width'];
|
||||||
|
Loading…
Reference in New Issue
Block a user