i`m noobie in php, just creating image resize script. Following code is about what i try to do. Particularly - try to understand how to resize an image after addition , but face with some issue. Please, help me , what is wrong with my code ?
$temp = getimagesize($_FILES['file']['tmp_name']);
$name = '/upload/'.date('Ymd-His').'img'. rand(10000, 99999).'.jpg';
if (!in_array($matches[1], $array2)) {
$errors['file'] = 'Wrong file extension';
} elseif (!in_array($temp['mime'], $array)) {
$errors['file'] = 'Wrong type of file';
} elseif (!move_uploaded_file($_FILES['file']['tmp_name'],'.'.$name)){
$errors['file'] = 'image is not loaded';
} else {
// there is a problem
$tmp = imagecreatetruecolor(200, 150);
$image = imagecreatefromjpeg($name);
imagecopyresampled($tmp, $image, 0,0,0,0, 200, 150, $temp[0], $temp[1]);
imagejpeg($tmp, 100);
// which i can`t fix
}
} else {
$errors['file'] = 'The file is not an image. Valid file types: jpg, png, gif';
}
}
}