Jump to content

Cross Browser Alert Problems


greenday

Recommended Posts

Hi

 

I am using PHP File Upload add on to Dreamweaver, and am getting some serious cross browser probs. Its an extension which allows form data file fields to upload to a directory, and insert the name into a DB. There are options to limit file size and dimensions etc.

 

If the dimensions of the intended image are too big, an alert box will pop up with a message saying the size is too big. If you still try to submit the form regardless, the alert will come up again, and not allow the form to submit.

 

This works fine in IE6, but in IE7 and FF3, the alerts will not appear (except if the file is not an image), and allows the form to be submitted, going to a detail error page with a back button. Once the back back is pressed, the form has lost all the inputed data, and the user gives up.

 

Here is an extract from the js file which should give the alert:

function showImageDimensions(fieldImg) {
  var is_ns6 = (!document.all && document.getElementById ? true : false);
  var img = (fieldImg && !is_ns6 ? 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);
      img.field.uploadOK = false;
      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);
      img.field.uploadOK = false;
      return;
    }
    if (img.sizeLimit != '' && img.fileSize > img.sizeLimit) {
      alert('Uploaded Image File Size is too big!\nShould be max ' + (img.sizeLimit/1024) + ' KBytes');
      img.field.uploadOK = false;
      return;
    }
    if (img.saveWidth != '') {
      document.PU_uploadForm[img.saveWidth].value = img.width;
    }
    if (img.saveHeight != '') {
      document.PU_uploadForm[img.saveHeight].value = img.height;
    }
    if (document.PU_uploadForm[img.field.name+'_width']) {
      document.PU_uploadForm[img.field.name+'_width'].value = img.width;
    }
    if (document.PU_uploadForm[img.field.name+'_height']) {
      document.PU_uploadForm[img.field.name+'_height'].value = img.height;
    }
    img.field.uploadOK = true;
  }
}

 

Any help much appreciated

 

Link to comment
Share on other sites

  • 4 years later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.