2

i am uploadind an image in php using copy function. my imade doesnt display when the image height is less than 981pz & width is less than 477pz

1
  • Wow you should first read your message over before posting? It does not make complete sense to me. Commented Sep 18, 2010 at 2:08

4 Answers 4

1

image size validator usually place in php code/server side.

after user upload the file you can check the size of image using

list($width, $height) = getimagesize($img_path)

if ($width > x )
    do something

if ($height > x)
    do something

if you want to check file type and also image resolution uploaded by user, can use

$info = getimagesize("my-great-photo.jpg");

and the result is:
Array
(
    [0] => 300 //width
    [1] => 200 //height
    [2] => 2
    [3] => width="300" height="200"
    [bits] => 8 //size
    [channels] => 3
    [mime] => image/jpeg //image type
)

$width = $info[0];
$height = $info[1];
$type = $info[mime]

check this documentation

Sign up to request clarification or add additional context in comments.

Comments

0

Your question is not very clear. But if you are looking for a way in PHP to find the height and width of an image you can use the getimagesize function.

You can use it as:

list($width,$height) = getimagesize($image_file_name);

Comments

0

Using the copy function is not supported by all hosts, and is considered to be a security risk. If you would like to upload an image to your server, look into creating an HTML form like what has been done here. If you do this, you will be able to get the mime type from the $_FILES array, and know not only whether or not you are uploading a picture, but also what type of picture you are upload (e.g. png, jpeg, gif).

Comments

0

If you're looking for a way to restrict uploaded image size, then as others said you can use getimagesize function, but if it is an issue with displaying the image, you can use a script like timthumb, which you pass image path to, and it will resize it to the dimensions you specify (on fly).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.