我正在尝试验证用户上传的图像.因此,在用户添加其图像之后,在将其上载到服务器上之前,我尝试使用下面的javascript代码验证图像尺寸,但它不起作用.
function check_image_dimensions(){
var t=document.getElementById("main_file_1");
e=t.clientWidth;
n="";
o="We could not upload your image because \n \n";
if (e<300) {
(n+="The height of the image must be greater than 300px \n";
}
if(i<300){
n+="The height of the image must be greater than 300px \n";
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
e=t.width;
i=t.height;
Run Code Online (Sandbox Code Playgroud)
但它仍然无效.我究竟做错了什么?
谢谢!