开发者

check image size before upload [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

checking image size before upload

I want to check image size before upload photo using JavaScript

  • Max width = 1024px
  • Max Hight = 800px

How can this be done?

<script>
<!-- HERE MY QUESTION -->
</script>    
<form name="forms" action="#" method="post" enctype="multipart/form-data" onsubmit="return check();">        
    <input type="file" name="img_name" /><br />
    <input type="submit" valu开发者_如何学Goe="Upload" />        
</form>


You can't access the image until it has been uploaded to your server, or if you use Flash to do it.

On upload, you can use list($width, $height) = getimagesize($_FILES['file']['tmp_name']) for example, using PHP. If the dimensions exceed your specification, remove the file and alert the user.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜