Skip to content
Advertisement

How to check image width and height before upload image in uploadify?

Below is the uploadify plugins , here I want to use code for validate image dimension(width and height) before upload.

<script>
$(function() {
$("#file_upload_1").uploadify({
height        : 30,
swf           : '/uploadify/uploadify.swf',
uploader      : '/uploadify/uploadify.php',
width         : 120
});
});
</script>

Advertisement

Answer

You get the size of the image on this line:

$size = getimagesize($pathToFullImage);

Why not add a conditional here to check if it is at least the size you want, and if not return an error.

if($size[0] > 150 || $size[1] > 150) {
  return $someError;
}

Also it looks like there is an onError option for Uploadify which you could set: http://www.uploadify.com/documentation/

EDIT: This thread looks like it could be of some help to you: http://www.uploadify.com/forum/viewtopic.php?f=5&t=14

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement