<?
$max_image_width= 2000;
$max_image_height= 2000;
$max_image_size= 2000 * 1024;
$valid_types = array("jpg", "gif");
if (isset($_FILES["userfile"])) {
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
$filename = $_FILES['userfile']['tmp_name'];
$ext = substr($_FILES['userfile']['name'],
1 + strrpos($_FILES['userfile']['name'], "."));
if (filesize($filename) > $max_image_size) {
echo 'Error: Максимальный размер файла 200 K.';
} elseif (!in_array($ext, $valid_types)) {
echo 'Error: Непойми чё послал.. Не хорошо.';
} else {
$size = GetImageSize($filename);
if (($size) && ($size[0] < $max_image_width)
&& ($size[1] < $max_image_height)) {
if (@move_uploaded_file($filename, "foto/121.jpg")) {
require ('imgresize.php');
if (img_resize('foto/121.jpg', 'foto/small/121.jpg', 100, 100))
echo 'Image resized OK';
else
echo 'Resize failed!';
echo 'File successful uploaded.';
} else {
echo 'Error: moving fie failed.';
}
} else {
echo 'Error: invalid image properties.';
}
}
} else {
echo "Error: empty file.";
}
} else {
echo '
<form enctype="multipart/form-data" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="6400000">
Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">
</form>';
}
?>