Javascript を使用して PHP に画像をアップロードする前に、画像の解像度を検証したいと考えています。私のphpフォームで、2つの異なる画像をアップロードしたいのですが、両方の画像に異なる解像度制限があります。
次のコードを試します
PHPコード
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'>";
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 //
}
ここでは、異なるサイズのファイルを選択しても、両方の画像の幅と高さを同じにしています。
これを行う方法?私に提案してください
前もって感謝します