new Image().src='c:\file.jpg' does not work under firefox?
I want to get the width/heigh value of picture
iProgram
4:45 am on Feb 20, 2006 (gmt 0)
I have a web form which lets visitor to upload picture to my server. The requirement is all these pictures should be 80x80 px. I use the following method to check image size:
<input onchange="check(this)" type="file" /> function check(f) { var img = new Image(); img.src = f.value; alert(img.width + ' x ' + img.height); }
It works under IE but Firefox/Opera alert "0 x 0". Please help.
DrDoc
5:12 am on Feb 20, 2006 (gmt 0)
That is a safety measure. You do not have direct access to file objects on the remote system. Unfortunately, IE gives you that access.
iProgram
7:21 am on Feb 20, 2006 (gmt 0)
So no way?
garyr_h
7:32 pm on Feb 20, 2006 (gmt 0)
You could try using an alternative language like PHP and use the getimagesize() function which will do what you want.
kaled
8:09 pm on Feb 20, 2006 (gmt 0)
Does it work if the image is rendered in the page (rather than simply using an abstract object)?
Kaled.
Bernard Marx
10:36 pm on Feb 20, 2006 (gmt 0)
No. In FF, an image src can't be set to a path within the filesystem by a page on a server (I tried. The JS console said something along those lines).