I want to validate Image Resolution before upload an image in PHP through Javascript. In my php form , i want to upload two different images and both image have different resolution restriction.
I try the following code
PHP Code
echo "<form name='add' enctype='multipart/form-data' action='AppActions.php' method='post' onSubmit='return validate_create();'>";
echo "<div class='form_label'>Album Wrapper (Big Image) *</div>";
echo "<div class='form_input'><input type='file' name='bigimage' id='bigimage' />";
echo "<div class='form_label'>Album Wrapper (Small Image) *</div>";
echo "<div class='form_input'><input type='file' name='smallimage' id='smallimage' />;
echo "<input type='submit' name='add' value='Create' class='Buttons' id='add'>";
In Javascript
function validate_create()
{
var bigimage = document.getElementById('bigimage');
var smallimage = document.getElementById('smallimage');
var big_img_width = bigimage.clientWidth;
var big_img_height = bigimage.clientHeight;
var small_img_width = smallimage.clientWidth;
var small_img_height = smallimage.clientHeight;
// if condtion to check the condition //
}
Here i am getting width and height for both images as same even i choose different size files.
How to do this? please suggest me
Thanks in advance