简体   繁体   中英

How to get the Uploading images height and width using javascript

In this case i am uploading an image using HTML and JavaScript.

I need to upload an image with only in the size of width->400 and height->400.

How can this be done using java script.

thanks in advance.

I don't think you can with Javascript (maybe with HTML5?). Regardless, you wouldn't want to do input checking on the client side because users (not all) are malicious or perhaps could just javascript blocked.

A better "solution" is to let them upload it, check the width and height of the picture, and if isn't what you want then present a message to the user like "Error: Picture is too big, decrease picture size!"

Or another solution would be to scale it for them to that size once they upload it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM