开发者

Using Javascript Image object to handle images

开发者 https://www.devze.com 2022-12-15 14:36 出处:网络
I need to preview an image using javascript before upload to provide a crop facility. For this purpose, I create an Image object in javascript.

I need to preview an image using javascript before upload to provide a crop facility. For this purpose, I create an Image object in javascript.

var image = new Image();

To confine big images to a limited space, I access the height and width of the image us开发者_Python百科ing image.width and image.height

For some of the images, I find that this value is shown as zero and for which when I inspected the image object, found that image.mimeType has the value Unspecified Error (Even the file creationdate shows unspecified error).

As such I am not able to preview those images. How do I solve the problem?


You won't be able to get a preview of image from the client system. You have to upload the image to a server and can show the image preview from there.

Reading files from the client system is a security threat and most browsers won't allow that. In earlier versions of IE you can get that, but won't be available in newer versions and other browsers.

0

精彩评论

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

关注公众号