Hey guys im trying to add a max with of the image that it is going to upload i cant seem to do that someone give me a hand be greatly helpfull thanks
<?
// CONFIG
$serverpath = ""; // Path to where images should be uplothe server.
$urltoimages = ""; // Web address to where the images are accessible from.
$maxsize = "1000000"; // Example - 20000 is the same as 20kb
$uniq = uniqid("");
// CONFIG END
$mode = $_GET['mode'];
if ($mode == "") { $mode = "form"; }
if ($mode == "form") {
echo "<form enctype='multipart/form-data' method='post' action='?mode=upload'>\n";
echo "<input type='file' name='file'>\n";
echo "<input type='submit' name='Submit' value='Go'>\n";
}
if ($mode == "upload") {
$file = $_FILES['file']['name'];
$name = time() . substr($file, -4);
// If you add your own file types don't forget to add an uppercase version.
$allowedfiles[] = "gif";
$allowedfiles[] = "jpg";
$allowedfiles[] = "jpeg";
$allowedfiles[] = "png";
$allowedfiles[] = "GIF";
$allowedfiles[] = "JPG";
$allowedfiles[] = "JPEG";
$allowedfiles[] = "PNG";
if($_FILES['file']['size'] > $maxsize)
{
print "File size is too big - please reduce file size and try again.";
}
else {
$path = "$serverpath/" . $name;
foreach($allowedfiles as $allowedfile) {
if ($done <> "yes") {
if (file_exists($path)) {
echo "A file with this name already exists - please rename the file and reupload.";
exit;
}
}
if (substr($file, -3) == $allowedfile) {
move_uploaded_file($_FILES['file']['tmp_name'], "$path");
$done = "yes";
echo "<p>Your image has been successfully uploaded to our server and can be accessed using the URL provided below.</p>";
echo "<p><A href='$urltoimages/$name' target='_blank'><strong>$urltoimages/$name</strong></a></p>";
echo "<p><img src='$urltoimages/$name' border='0'>";
}
}
if ($done <> "yes") { print "<p><b>Error:</b> Your image as not been uploaded becuase it is not a recognised image file. Please try again.</p>"; }
}
}
?>