Hi all,
How do i restrict the image's dimension that is being uploaded via a php script.?
I am using cakephp v 1.2
thanks
Hi all,
How do i restrict the image's dimension that is being uploaded via a php script.?
I am using cakephp v 1.2
thanks
You'll have to wait until the file is uploaded then call getimagesize()
to check the dimensions and print an error if it's too big.
You can't check the size before the upload is complete.
Without something on the client side which can see the file system (like a Java applet), you can't know it in advance.
Best you can do is inspect the file with GetImageSize after it has been uploaded, but before you do anything important with it.
list($width, $height) = getimagesize($_FILES['myfile']['tmp_name']);
Unfortunately you only can check the dimensions after upload with
list($imagewidth, $width) = getimagesize("$myupload");
in php you can grab the file dimensions while the file is being uploaded.
You might want to use:
... to check the dimensions before upload.
Consider always the way of a front-end, PHP should be combined with client-sided tools/languages/apps to make it more efficient. ;)