Loading ...
Sorry, an error occurred while loading the content.

Upload file: response Text returns undefined value in IE browser

Expand Messages
  • false
    Hello everybody, At this moment, I am encountering an issue I have not found the way to solve yet. Please give me a clue if you can. Many thanks in advance! I
    Message 1 of 2 , Nov 7, 2009
    • 0 Attachment
      Hello everybody,

      At this moment, I am encountering an issue I have not found the way to solve yet. Please give me a clue if

      you can. Many thanks in advance!

      I am developing a module allowing users to upload image file to server with CodeIgniter and YUI. There

      are some restrictions for this upload: image files only, .GIF, JPG, ... and the maximum capacity for the

      uploaded file not exceed 1 Megabyte. And the following is my JS code:

      function uploadPhoto()
      {

      setGlobalMessage("");
      var sURL = _APBMRootURL + "adminMembers_controller/uploadPhoto";

      var callback =
      {
      upload: handleUploadPhotoUpload,
      failure: handleUploadPhotoFailure
      };

      var f = document.getElementById("frm_Main");
      var postData = YAHOO.util.Connect.setForm(f, true);
      var request = YAHOO.util.Connect.asyncRequest('POST', sURL, callback);

      }

      function handleUploadPhotoUpload(o)
      {
      //alert(o.reponseText);
      if (o.responseText == undefined || o.responseText == null)
      {
      setGlobalMessage("Connection timeout. Please try again later.");
      ///setGlobalMessage("The size for the uploaded image should not exceed 1Mbs.");
      return;
      }
      ...
      }

      function handleUploadPhotoFailure(o)
      {
      .....
      }

      In IE, I got o.responseText with undefined value whenever I upload the file with the capacity larger than the

      allowed maximum capacity as I mentioned above.

      While I do not get this issue in Firefox.

      Many thanks for your assistance!

      Best Regards,

      Nhat
    • Matt
      Hi, A couple of points: I m not sure if they ll help with the immediate problem, though! 1. I don t think the upload case ever calls a failure handler - they
      Message 2 of 2 , Nov 7, 2009
      • 0 Attachment
        Hi,

        A couple of points: I'm not sure if they'll help with the immediate problem, though!

        1. I don't think the upload case ever calls a failure handler - they all go to upload (check http://developer.yahoo.com/yui/connection/#upload)
        2. It's not clear if you're using an SSL connection, but if so you'll need the third argument in setForm set to true:
        var postData = YAHOO.util.Connect.setForm(f, true, true);
        3. test for undefined using ===, rather than ==
        4. o.responseText should be what's in the iframe that's used for the upload (see the docs linked above), but I'm not sure of the detail of this. Is the filesize enforcement at the form or server? That may affect things. What does your server return if the file is too big?

        Hope that's helpful, but may not be!

        Matt

        --- In ydn-javascript@yahoogroups.com, false <htnhat@...> wrote:
        >
        > Hello everybody,
        >
        > At this moment, I am encountering an issue I have not found the way to solve yet. Please give me a clue if
        >
        > you can. Many thanks in advance!
        >
        > I am developing a module allowing users to upload image file to server with CodeIgniter and YUI. There
        >
        > are some restrictions for this upload: image files only, .GIF, JPG, ... and the maximum capacity for the
        >
        > uploaded file not exceed 1 Megabyte. And the following is my JS code:
        >
        > function uploadPhoto()
        > {
        >
        > setGlobalMessage("");
        > var sURL = _APBMRootURL + "adminMembers_controller/uploadPhoto";
        >
        > var callback =
        > {
        > upload: handleUploadPhotoUpload,
        > failure: handleUploadPhotoFailure
        > };
        >
        > var f = document.getElementById("frm_Main");
        > var postData = YAHOO.util.Connect.setForm(f, true);
        > var request = YAHOO.util.Connect.asyncRequest('POST', sURL, callback);
        >
        > }
        >
        > function handleUploadPhotoUpload(o)
        > {
        > //alert(o.reponseText);
        > if (o.responseText == undefined || o.responseText == null)
        > {
        > setGlobalMessage("Connection timeout. Please try again later.");
        > ///setGlobalMessage("The size for the uploaded image should not exceed 1Mbs.");
        > return;
        > }
        > ...
        > }
        >
        > function handleUploadPhotoFailure(o)
        > {
        > .....
        > }
        >
        > In IE, I got o.responseText with undefined value whenever I upload the file with the capacity larger than the
        >
        > allowed maximum capacity as I mentioned above.
        >
        > While I do not get this issue in Firefox.
        >
        > Many thanks for your assistance!
        >
        > Best Regards,
        >
        > Nhat
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.