This simple code wont let u put a image wider than 150px.
$sizearray = getimagesize("img_name.jpg");
$width= $size[0];
if($width>150)
{
echo "its wider than 150px";
}
TechySafi
Junior Poster in Training
99 posts since Oct 2010
Reputation Points: 10
Solved Threads: 14
if(isset($_POST['imageInsert']))
{
$current_image=$_FILES['image']['name'];
$imageextension = substr(strrchr($current_image, '.'), 1);
$sizearray = getimagesize('$current_image'); //seems we have a var to retrieve the name
$width= $size[0];
if (($imageextension!= "jpg") or ($imageextension != "jpeg") or ($imageextension != "gif")) //changed to OR
{
die('Unknown extension. Only jpg, jpeg, and gif files are allowed. Please hit the back button on your browser and try again.'); //if this test is passed
}
elseif($width>150) //now check the width....
{
die ('its wider than 150px');
}
else //everythings fine...now proceed, i put an extra "}" at the end for this extra else condition (it wasnt in ur code)
{
$time = date("fYhis");
$imagecaption = $_POST["imagecaption"];
$new_image = $imagecaption . "." . $imageextension;
$destination="../logos/".$current_image;
$action = copy($_FILES['image']['tmp_name'], $destination);
if (!$action)
{
die('File copy failed. Please hit the back button.');
}
else{
}
}
That should work fine...does it?
TechySafi
Junior Poster in Training
99 posts since Oct 2010
Reputation Points: 10
Solved Threads: 14