G
Gianpiero Colagiacomo
Hi,
I'm trying to use the following code (found online - can't remember where)
to validate images being uploaded to my server:
function checkImageUpload (fileName) {
if (document.layers && location.protocol.toLowerCase() != 'file:' &&
navigator.javaEnabled()){
netscape.security.PrivilegeManager.enablePrivilege('UniversalFileRead');
}
var msg = '';
var img = new Image();
img.src = 'file:///' + fileName;
if (img.width != 180 || img.height != 90){
msg = "The selected image dimensions are not valid. The image must be 180
x 90 pixels.\n\n";
msg = msg + "Your selected image dimensions are " + img.width + " x " +
img.height;
alert('The required information is incomplete or contains
errors:\t\t\t\t\t\n\n'+msg);
return false
} else {
return true
}
}
Trouble is it won't work in Netscape. I get 0 x 0 pixels reported as being
the image size although the if(document.layers... line should be dealing
with Netscape issues (I think)...
What I ultimately want is to be able to make this script cross browsers
compatible and cross platform is possible...
Can anyone help me out? I'd prefer not to have to revert to validating the
file AFTER having uploaded it...
I also need to be able to make the script only accept jpg's and gif's - is
there an easy method of achieving this?
Cheers,
GP
I'm trying to use the following code (found online - can't remember where)
to validate images being uploaded to my server:
function checkImageUpload (fileName) {
if (document.layers && location.protocol.toLowerCase() != 'file:' &&
navigator.javaEnabled()){
netscape.security.PrivilegeManager.enablePrivilege('UniversalFileRead');
}
var msg = '';
var img = new Image();
img.src = 'file:///' + fileName;
if (img.width != 180 || img.height != 90){
msg = "The selected image dimensions are not valid. The image must be 180
x 90 pixels.\n\n";
msg = msg + "Your selected image dimensions are " + img.width + " x " +
img.height;
alert('The required information is incomplete or contains
errors:\t\t\t\t\t\n\n'+msg);
return false
} else {
return true
}
}
Trouble is it won't work in Netscape. I get 0 x 0 pixels reported as being
the image size although the if(document.layers... line should be dealing
with Netscape issues (I think)...
What I ultimately want is to be able to make this script cross browsers
compatible and cross platform is possible...
Can anyone help me out? I'd prefer not to have to revert to validating the
file AFTER having uploaded it...
I also need to be able to make the script only accept jpg's and gif's - is
there an easy method of achieving this?
Cheers,
GP