PDA

For continued disscussion on this topic : image dimension



sindhu
07-03-2000, 10:29 AM
Hello ,

I am sindhu a new user of this site..hope i'll get some usefull information.

I am in need of a help..!

I have an html element like this..!
<input type=file name="fil_name" value="">

so i have an textbox followed by an browser button.

When i click on the browser button and select an image...When validating i am validating for the image that i have entered...

I am getting the dimension of the image if the width and height exceeds 100 i must give an alert saying itexceeds the limit and my cursor should be focused back to my image type="file"..!

I have a code which isworking fine in IE but not Netscape..

Can anyone help me out...!

Thanks in advance..!

Regards
Sindhuja.J

Vincent Puglia
07-03-2000, 12:46 PM
Hello Sindu,

I moved the thread here because the "Post..." forum is not for problems.

Could we see some code. otherwise, we'll be giving you some advice you already rejected or can't follow like--
1) document.formname.textboxname.focus().

Vinny

sindhu
07-03-2000, 12:53 PM
<!--Begining of a function to check the dimensions of an image-->
function checkImageDimensions (fileName,result)
{
var browser=navigator.appName
var version=navigator.appVersion
var var1 =version.substring(0,1)
var imgURL = 'file:///' + fileName;
var img=new Image();
img.src =imgURL;
alert(img.src)
if (document.layers && location.protocol.toLowerCase() != 'file:' && navigator.javaEnabled())
netscape.security.PrivilegeManager.enablePrivilege('UniversalFileRead');

if((browser=="Netscape") && (var1 >=4))
{
self.setTimeout('netdimension()',5000 )
}

var ht = img.height;
var wid = img.width;


if((img.height>100) || (img.width>100))
{
alert(result + " is invalid - not to exceed 100 x 100 dimension")
return false;
}
else((wid<100) || (ht<100))
return true;
}
<!--End of a function to check the dimensions of an image-->
function netdimension()
{
return true;
}



i am validating it as

if(!checkImageDimensions(attach2,"Product Attachment2"))
{
document.frm_post.File_prdImage2.focus()
return false;
}

Sir i have no problem when this is an HTML page but when it's an asp page it give me problem in the source part of the code...!

Vincent Puglia
07-03-2000, 02:59 PM
Hi Sindhu,


Maybe I'm just reading it wrong, but...the following:

location.protocol.toLowerCase() != 'file:'

...says you are not looking for a local file; and this implies you are:

<input type=file name="fil_name" value="">


Finally, regarding:



Sir i have no problem when this is an HTML page but when it's an asp page it give me problem in the source part of the code...!



Since it works with IE, the culprit may be in your html syntax. IE allows many shortcuts; NN does not. For example, do you have opening & closing form tags?
Did you try using alerts to localize the error line?

Oh...one more thing: please don't call me "Sir" -- I'm old enough as it is; don't need to get any older. :)

Vinny

sindhu
07-04-2000, 05:30 AM
Hello,

My code works fine in netscape and ie...when saved in my local machine...but when i put it in my webserver....the problem arises...!

By the way i really can't get the meaning of

"
location.protocol.toLowerCase() != 'file:'

...says you are not looking for a local file; and this implies you are:

<input type=file name="fil_name" value="">
"

Thanks in advance

SindhujaJawahar

Vincent Puglia
07-04-2000, 01:17 PM
Hi Sindhu,

location.protocol.... != 'file...' says: if the string 'file' is not part of the location's url -- and then you set the read rights for netscape. If you are uploading a file (which is what the "<input type='file'... code does, shouldn't "!=" be "==" ? Also, why are you setting enablePrivilege for netscape? My understanding is that that property is for other domains' files, not local files (but I can be wrong).

Where are you trying to upload the image file from? And exactly which part of the code is not working?

Vinny

sindhu
07-04-2000, 01:28 PM
Hello ,

Thanku...anyway...when i put my code in the webserver and when i try to access it as http://192.../sd/ww.html...then i am having problem with that enable property and aswell as with the source...!

Can u help me

Sindhuja.J