i wanted to know what's the best way to make my 3mb photo smaller on upload i have this upload form but for some reason it wont upload images over 2mb i keep getting "file is too small or large" PHP ONLY
$valid_exts = array('jpeg', 'jpg', 'png', 'gif');
$max_file_size = 2000000 * 1234567;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ( isset($_FILES['image']) ) {
if (! $_FILES['image']['error'] && $_FILES['image']['size'] < $max_file_size) {
$ext = strtolower(pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION));
if (in_array($ext, $valid_exts)) {
if (!file_exists('photos/' )) {
mkdir('photos/' , 0777, true);
}
$path = 'photos/' . uniqid() . '.' . $ext;
$size = getimagesize($_FILES['image']['tmp_name']);
$x = (int) $_POST['x'];
$y = (int) $_POST['y'];
$w = (int) $_POST['w'] ? $_POST['w'] : $size[0];
$h = (int) $_POST['h'] ? $_POST['h'] : $size[1];
$data = file_get_contents($_FILES['image']['tmp_name']);
$vImg = imagecreatefromstring($data);
$dstImg = imagecreatetruecolor($w, $h);
imagecopyresampled($dstImg, $vImg, 0, 0, $x, $y, $w, $h, $w, $h);
imagejpeg($dstImg, $path);
imagedestroy($dstImg);
/*print_r($path);*/
} else {
echo 'unknown problem!';
}
} else {
echo 'file is too small or large';
}
} else {
echo 'file not set';
}
} else {
echo 'bad request!';
}