views:

53

answers:

2

How do i make a limit for the size of the image not SIZE but i mean how big it is.. so max 150x150?

$image=$_FILES['image']['name'];
  if ($image) 
  {
   $filename = stripslashes($_FILES['image']['name']);
    $extension = getExtension($filename);
   $extension = strtolower($extension);
 if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) 
   {
    echo '<h1>Fel bildformat, duuh!!</h1>';
    $errors=1;
   }
   else
   {
 $size=filesize($_FILES['image']['tmp_name']);
if ($size > MAX_SIZE*1024)
{
 echo '<h1>Bilden är över tillåten storlek..tyvärr</h1>';
 $errors=1;
}
$image_name=time().'.'.$extension;
$newname="cars/".$image_name;
$copied = copy($_FILES['image']['tmp_name'], $newname);
if (!$copied) 
{
 echo '<h1>Kopiering gick fel.. testa igen!</h1>';
 $errors=1;
}}}
+2  A: 

You need to use a image editing library for this functionality. Like GD

Ropstah
More specifically: http://www.php.net/manual/en/function.getimagesize.php
Ropstah
+2  A: 

you have to use getimagesize() to check image dimensions

zerkms