Solved

Pure ASP File Upload - Form not submitting in IE 7

Posted on 2007-11-22
13
630 Views
Last Modified: 2013-12-08
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..:)
0
Comment
Question by:fgict
  • 5
  • 4
  • 2
13 Comments
 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
If nothing happens when the submit button is pressed then the issue is most likely either html or Javascript (clientside script).  ASP and that upload object are on the server so would not be the cause if the page is never even submitted.

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
0
 
LVL 22

Expert Comment

by:RedKelvin
Comment Utility
Are you relying on Javascript, maybe the client has it disabled

RedK
0
 
LVL 1

Author Comment

by:fgict
Comment Utility
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>*&nbsp;</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>&nbsp;</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>

Open in new window

0
 
LVL 22

Expert Comment

by:RedKelvin
Comment Utility
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
0
 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
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
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
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
0
 
LVL 1

Author Comment

by:fgict
Comment Utility
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 :(
0
 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
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
0
 
LVL 1

Author Comment

by:fgict
Comment Utility
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%20Settings/All%20Users/Documents/My%20Pictures/Sample%20Pictures/Winter.jpg.
0
 
LVL 1

Accepted Solution

by:
fgict earned 0 total points
Comment Utility
Finally found the walk-around:
IE7 USERS - SPECIAL NOTE
Due to the new scripting and security procedures utilized in IE7 ASP Gallery users with IE7 may encounter some issues uploading images. The fix for this is simply to add your site to the list of your local trusted sites in IE (http://www.yoursite.com).

It finally worked for me on IE 7
Thanks for all your help
0
 
LVL 1

Author Comment

by:fgict
Comment Utility
Hi b0lsc0tt

Yes, the problem is solved, thanks for all your help.  You may close the question as best you see. regards,
fgict
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Internet is a big network which is formed by connecting multiple small networks.It is a platform for all the users which are connected to it.Internet act as platform in different fields. Such as: Internet  as a collaboration platform. Internet  as…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now