PHP: upload image max 150x150

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

  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>';
if ($size > MAX_SIZE*1024)
 echo '<h1>Bilden är över tillåten storlek..tyvärr</h1>';
$copied = copy($_FILES['image']['tmp_name'], $newname);
if (!$copied) 
 echo '<h1>Kopiering gick fel.. testa igen!</h1>';


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

you have to use getimagesize() to check image dimensions

Need Your Help

Java applet 2d graphics drawing issue when drawing twice (black parts)

java applet drawing 2d

So i had a console game i made, and i thought in making it 2d.

User control blank on form in VS 2008

c# visual-studio-2008 user-controls

I've created a user control that contains a table layout control with various other standard controls like buttons and labels. Yet when I add the user control to one of my forms the control is blan...