fgict
asked on
Pure ASP File Upload - Form not submitting in IE 7
Hi,
I have a form which the user can upload images to a gallery (and it saves input to database plus creating thumbnails of the images), it is working ok on IE 5 & IE 6, but a client contacted me to say when they click the submit button nothing happens. They are running IE 7 on Vista.
I am using Pure ASP File Upload v.2
Any help would be greatly appreciated..:)
I have a form which the user can upload images to a gallery (and it saves input to database plus creating thumbnails of the images), it is working ok on IE 5 & IE 6, but a client contacted me to say when they click the submit button nothing happens. They are running IE 7 on Vista.
I am using Pure ASP File Upload v.2
Any help would be greatly appreciated..:)
Are you relying on Javascript, maybe the client has it disabled
RedK
RedK
ASKER
Hi all,#thanks for response, i posted the page code below..this one has me puzzled :(
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Admin</title>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<script language="JavaScript">
<!--
function checkFileUpload(form,extensions,requireUpload,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight) { //v2.09
document.MM_returnValue = true;
for (var i = 0; i<form.elements.length; i++) {
field = form.elements[i];
if (field.type.toUpperCase() != 'FILE') continue;
checkOneFileUpload(field,extensions,requireUpload,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight);
} }
function checkOneFileUpload(field,extensions,requireUpload,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight) { //v2.09
document.MM_returnValue = true;
if (extensions != '') var re = new RegExp("\.(" + extensions.replace(/,/gi,"|").replace(/\s/gi,"") + ")$","i");
if (field.value == '') {
if (requireUpload) {alert('File is required!');document.MM_returnValue = false;field.focus();return;}
} else {
if(extensions != '' && !re.test(field.value)) {
alert('This file type is not allowed for uploading.\nOnly the following file extensions are allowed: ' + extensions + '.\nPlease select another file and try again.');
document.MM_returnValue = false;field.focus();return;
}
document.PU_uploadForm = field.form;
re = new RegExp(".(gif|jpg|png|bmp|jpeg)$","i");
if(re.test(field.value) && (sizeLimit != '' || minWidth != '' || minHeight != '' || maxWidth != '' || maxHeight != '' || saveWidth != '' || saveHeight != '')) {
checkImageDimensions(field,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight);
} }
}
function showImageDimensions(fieldImg) { //v2.09
var isNS6 = (!document.all && document.getElementById ? true : false);
var img = (fieldImg && !isNS6 ? fieldImg : this);
if (img.width > 0 && img.height > 0) {
if ((img.minWidth != '' && img.minWidth > img.width) || (img.minHeight != '' && img.minHeight > img.height)) {
alert('Uploaded Image is too small!\nShould be at least ' + img.minWidth + ' x ' + img.minHeight); return;}
if ((img.maxWidth != '' && img.width > img.maxWidth) || (img.maxHeight != '' && img.height > img.maxHeight)) {
alert('Uploaded Image is too big!\nShould be max ' + img.maxWidth + ' x ' + img.maxHeight); return;}
if (img.sizeLimit != '' && img.fileSize > img.sizeLimit) {
alert('Uploaded Image File Size is too big!\nShould be max ' + (img.sizeLimit/1024) + ' KBytes'); return;}
if (img.saveWidth != '') document.PU_uploadForm[img.saveWidth].value = img.width;
if (img.saveHeight != '') document.PU_uploadForm[img.saveHeight].value = img.height;
document.MM_returnValue = true;
} }
function checkImageDimensions(field,sizeL,minW,minH,maxW,maxH,saveW,saveH) { //v2.09
if (!document.layers) {
var isNS6 = (!document.all && document.getElementById ? true : false);
document.MM_returnValue = false; var imgURL = 'file:///' + field.value.replace(/\\/gi,'/').replace(/:/gi,'|').replace(/"/gi,'').replace(/^\//,'');
if (!field.gp_img || (field.gp_img && field.gp_img.src != imgURL) || isNS6) {field.gp_img = new Image();
with (field) {gp_img.sizeLimit = sizeL*1024; gp_img.minWidth = minW; gp_img.minHeight = minH; gp_img.maxWidth = maxW; gp_img.maxHeight = maxH;
gp_img.saveWidth = saveW; gp_img.saveHeight = saveH; gp_img.onload = showImageDimensions; gp_img.src = imgURL; }
} else showImageDimensions(field.gp_img);}
}
//-->
</script>
<script language="JavaScript">
<!--
function checkFileUpload(form,extensions,requireUpload,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight) { //v2.09
document.MM_returnValue = true;
for (var i = 0; i<form.elements.length; i++) {
field = form.elements[i];
if (field.type.toUpperCase() != 'FILE') continue;
checkOneFileUpload(field,extensions,requireUpload,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight);
} }
function checkOneFileUpload(field,extensions,requireUpload,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight) { //v2.09
document.MM_returnValue = true;
if (extensions != '') var re = new RegExp("\.(" + extensions.replace(/,/gi,"|").replace(/\s/gi,"") + ")$","i");
if (field.value == '') {
if (requireUpload) {alert('File is required!');document.MM_returnValue = false;field.focus();return;}
} else {
if(extensions != '' && !re.test(field.value)) {
alert('This file type is not allowed for uploading.\nOnly the following file extensions are allowed: ' + extensions + '.\nPlease select another file and try again.');
document.MM_returnValue = false;field.focus();return;
}
document.PU_uploadForm = field.form;
re = new RegExp(".(gif|jpg|png|bmp|jpeg)$","i");
if(re.test(field.value) && (sizeLimit != '' || minWidth != '' || minHeight != '' || maxWidth != '' || maxHeight != '' || saveWidth != '' || saveHeight != '')) {
checkImageDimensions(field,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight);
} }
}
function showImageDimensions(fieldImg) { //v2.09
var isNS6 = (!document.all && document.getElementById ? true : false);
var img = (fieldImg && !isNS6 ? fieldImg : this);
if (img.width > 0 && img.height > 0) {
if ((img.minWidth != '' && img.minWidth > img.width) || (img.minHeight != '' && img.minHeight > img.height)) {
alert('Uploaded Image is too small!\nShould be at least ' + img.minWidth + ' x ' + img.minHeight); return;}
if ((img.maxWidth != '' && img.width > img.maxWidth) || (img.maxHeight != '' && img.height > img.maxHeight)) {
alert('Uploaded Image is too big!\nShould be max ' + img.maxWidth + ' x ' + img.maxHeight); return;}
if (img.sizeLimit != '' && img.fileSize > img.sizeLimit) {
alert('Uploaded Image File Size is too big!\nShould be max ' + (img.sizeLimit/1024) + ' KBytes'); return;}
if (img.saveWidth != '') document.PU_uploadForm[img.saveWidth].value = img.width;
if (img.saveHeight != '') document.PU_uploadForm[img.saveHeight].value = img.height;
document.MM_returnValue = true;
} }
function checkImageDimensions(field,sizeL,minW,minH,maxW,maxH,saveW,saveH) { //v2.09
if (!document.layers) {
var isNS6 = (!document.all && document.getElementById ? true : false);
document.MM_returnValue = false; var imgURL = 'file:///' + field.value.replace(/\\/gi,'/').replace(/:/gi,'|').replace(/"/gi,'').replace(/^\//,'');
if (!field.gp_img || (field.gp_img && field.gp_img.src != imgURL) || isNS6) {field.gp_img = new Image();
with (field) {gp_img.sizeLimit = sizeL*1024; gp_img.minWidth = minW; gp_img.minHeight = minH; gp_img.maxWidth = maxW; gp_img.maxHeight = maxH;
gp_img.saveWidth = saveW; gp_img.saveHeight = saveH; gp_img.onload = showImageDimensions; gp_img.src = imgURL; }
} else showImageDimensions(field.gp_img);}
}
//-->
</script>
<script language="javascript" src="../js/incPureUpload.js"></script>
<br> <table height="24" align="center">
<tr>
<td valign="top"><i>Fields with a</i></td>
<td valign="bottom" align="center"><font color="red" size="1"><b>* </b></font></td>
<td valign="top"><i>are mandatory.</i></td>
</tr>
</table><table width="450" align="center" cellpadding="3" cellspacing="0">
<tr>
<form action="/admin/gallery_add.asp?GP_upload=true" method="post" enctype="multipart/form-data" name="form1" onSubmit="checkFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,'','','','','','PIC_WIDTH','PIC_HEIGHT');return document.MM_returnValue">
<td align="center" valign="middle" bgcolor="#FFFFFF"> <table align="center" cellpadding="3" cellspacing="3" class="textBold">
<tr valign="baseline">
<td nowrap align="right">Category :</td><td><img style="cursor:hand" src="../img/help.gif" onMouseOver="helptip(event,0)" onMouseOut="hideTip()"></td>
<td> <select name="PIC_TYPE" class="form" id="PIC_TYPE">
<option value="2">Category 1</option>
<option value="3">Category 2</option>
<option value="4">Category 3</option>
</select> </td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Name :</td>
<td><img style="cursor:hand" src="../img/help.gif" onMouseOver="helptip(event,1)" onMouseOut="hideTip()"></td>
<td> <input name="PIC_NAME" type="text" class="form" value="" size="32" maxlength="20">
<font color="red" size="1"><b>*</b></font> </td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Image :</td>
<td><img style="cursor:hand" src="../img/help.gif" onMouseOver="helptip(event,3)" onMouseOut="hideTip()"></td>
<td> <input name="PIC_PICTURE" type="file" class="form" id="PIC_PICTURE" onChange="checkOneFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,'','','','','','PIC_WIDTH','PIC_HEIGHT')" size="35"></td>
</tr>
<tr>
<td nowrap align="right" valign="top">Description : </td>
<td valign="top"><img style="cursor:hand" src="../img/help.gif" onMouseOver="helptip(event,7)" onMouseOut="hideTip()"></td>
<td valign="baseline"> <textarea name="PIC_DESCRIPTION" cols="50" rows="5" class="form"></textarea> </td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Copyright : </td>
<td><img style="cursor:hand" src="../img/help.gif" onMouseOver="helptip(event,8)" onMouseOut="hideTip()"></td>
<td><input name="PIC_COPYRIGHT" type="text" class="form" value="" size="50"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> <input type="hidden" name="PIC_HEIGHT" value="" size="32">
<input type="hidden" name="PIC_WIDTH" value="" size="32">
<input type="hidden" name="PIC_APPROVED" value="1" size="32">
<input type="hidden" name="MM_insert" value="form1"> </td>
<td> </td>
<td> <input name="submit" type="submit" class="form" id="submit" value="Submit"> </td>
</tr>
</table></td>
</form>
</tr>
</table></td></tr></table>
</td>
</tr>
</table>
</body>
</html>
Yeah, that is Javascript driven, turn javascript off on your browser, and I bet it will not work. Certainly likely that is what is happening to your client
Can you duplicate the issue? Remove the code that calls the checkFileUpload() function in the onsubmit event. Does that make it so the form submits? Of course that won't work for good but it will help us narrow down the cause.
bol
bol
Have you reviewed that code? The code you posted has duplicate functions and it seems Javascript. Remove duplicates. You should also have the html validated. If there are validation errors then that will often interfere with script and can affect the page.
Let me know if you have questions about this.
bol
Let me know if you have questions about this.
bol
ASKER
Hi all,
Haven't yet had a chance to check in IE 7 Browser. Works great in IE 5 & IE 6, however, I have just noted that I have the same problem in FireFox, when I click submit on the form nothing happens, Javascript is turned on ok.
Perhaps it is unable to pickup the width and height of the image? Think I read about a similar bug in new browsers..still puzzled :(
Haven't yet had a chance to check in IE 7 Browser. Works great in IE 5 & IE 6, however, I have just noted that I have the same problem in FireFox, when I click submit on the form nothing happens, Javascript is turned on ok.
Perhaps it is unable to pickup the width and height of the image? Think I read about a similar bug in new browsers..still puzzled :(
Did you clean up the code? If so please post the new code you are using. Also, what image are you referring to? If you don't understand what I meant about cleaning the code up (remember the duplicate script I mentioned above) then let me know I can clarify.
Make sure you look at Firefox's Error Console (Ctrl + Shift + J) to see if there are any Javascript errors. Let me know if you have a question or need more info.
bol
Make sure you look at Firefox's Error Console (Ctrl + Shift + J) to see if there are any Javascript errors. Let me know if you have a question or need more info.
bol
ASKER
Hi b0lsc0tt
These are the 2 error messages I get in FireFox Error Console:
Warning: Error in parsing value for property 'cursor'. Declaration dropped.
Source File: http://www.mywebsite.com/admin/gallery_add.asp
Line: 0Security Error: Content at http://www.mywesite.com.com/admin/gallery_add.asp may not load or link to file:///C|/Documents%20and %20Setting s/All%20Us ers/Docume nts/My%20P ictures/Sa mple%20Pic tures/Wint er.jpg.
These are the 2 error messages I get in FireFox Error Console:
Warning: Error in parsing value for property 'cursor'. Declaration dropped.
Source File: http://www.mywebsite.com/admin/gallery_add.asp
Line: 0Security Error: Content at http://www.mywesite.com.com/admin/gallery_add.asp may not load or link to file:///C|/Documents%20and
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi b0lsc0tt
Yes, the problem is solved, thanks for all your help. You may close the question as best you see. regards,
fgict
Yes, the problem is solved, thanks for all your help. You may close the question as best you see. regards,
fgict
Can you duplicate it in IE7? Look for Javascript errors and let us know if there is one. Otherwise please post html and javascript that is part of the page (e.g. form and fields html and script associated).
Let me know if you have a question.
bol