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

Connection Manager, File Uploads and Internet Explorer

Expand Messages
  • Anthony Baratta
    Howdy... I m having issues with uploading files via IE. My code works great with Firefox, but with IE teh files are not being uploaded. The rest of the form
    Message 1 of 12 , Sep 28, 2006
    • 0 Attachment
      Howdy...

      I'm having issues with uploading files via IE. My code works great
      with Firefox, but with IE teh files are not being uploaded. The rest
      of the form data is there, but no files.

      Here the important parts of the code:


      function ajPostForm(sFormID, sFormName)
      {
      CheckObject();
      var sQueryString = "";
      var bFileUpload = false;
      switch (sFormName)
      {
      case "CardNote":
      sQueryString = "a=PostNote"
      break;
      case "CardImage":
      sQueryString = "a=PostImage";
      bFileUpload = true;
      break;
      }

      cbPostForm.argument = sFormName;
      YAHOO.util.Connect.setForm(sFormID, bFileUpload, true);
      cObj = YAHOO.util.Connect.asyncRequest('POST', './ajaxLib.aspx?' +
      sQueryString, cbPostForm, null);
      }

      var sPostForm = function(o)
      {
      //var aValues = eval( o.responseText );
      var aValues = o.responseText;
      oSwitch = o.argument;
      cObj = null;

      var sAction = "";
      var fdrCode = "0";
      switch (oSwitch)
      {
      case "CardNote":
      // Refresh Notes Grid
      sAction = "NoteList";
      fdrCode = document.getElementById("NoteFDRCode").value;
      break;
      case "CardImage":
      // Refresh Card Images
      sAction = "ImageList";
      fdrCode = document.getElementById("ImageFDRCode").value;
      break;
      }
      cbDataGrid.argument = oSwitch;

      cObj = YAHOO.util.Connect.asyncRequest('GET', './ajaxLib.aspx?a='
      + sAction + '&fID=' + fdrCode, cbDataGrid, null);

      alert("Returned: " + aValues);
      alert("sPostForm - " + oSwitch + ": " + './ajaxLib.aspx?a=' +
      sAction + '&fID=' + fdrCode);

      //o.responseText
      //o.argument
      }
      var fPostForm = function(o)
      {
      document.getElementById("errorDiv").innerHTML = o.statusText;
      cObj = null;
      //o.statusText
      }
      var cbPostForm =
      {
      success : sPostForm,
      upload : sPostForm,
      failure : fPostForm,
      argument: "dummy value"
      }


      The alert in the sPostForm returns me the number of files the
      ajaxLib.aspx page thinks are in the files container (dotNet 2.0). With
      Firefox the number is "2" and the files are dealt with properly. With
      IE the file count is "0".

      Any ideas???
    • Thomas S. Sha
      ... ... I m going to recreate your environment based on your source code, sans .aspx backend, and see if I can reproduce the report. Are
      Message 2 of 12 , Sep 28, 2006
      • 0 Attachment
        --- In ydn-javascript@yahoogroups.com, "Anthony Baratta"
        <a.baratta@...> wrote:
        >
        > Howdy...
        >
        > I'm having issues with uploading files via IE. My code works great
        > with Firefox, but with IE teh files are not being uploaded. The rest
        > of the form data is there, but no files.
        >
        <source code snipped>
        >
        > The alert in the sPostForm returns me the number of files the
        > ajaxLib.aspx page thinks are in the files container (dotNet 2.0). With
        > Firefox the number is "2" and the files are dealt with properly. With
        > IE the file count is "0".
        >
        > Any ideas???

        I'm going to recreate your environment based on your source code, sans
        .aspx backend, and see if I can reproduce the report. Are you serving
        this page in SSL? Your setForm arguments suggests this to be the case:
        * YAHOO.util.Connect.setForm(sFormID, bFileUpload, true);

        If not serving SSL, what happens in IE when you remove the third
        argument from setForm()?

        Regards,
        Thomas
      • Anthony Baratta
        ... Thomas... That was from testing. No I m not using SSL, and it does not work with or without the third parameter. ;-P I m currently trying to use the debug
        Message 3 of 12 , Sep 28, 2006
        • 0 Attachment
          --- In ydn-javascript@yahoogroups.com, "Thomas S. Sha" <tsha@...> wrote:
          > I'm going to recreate your environment based on your source code, sans
          > .aspx backend, and see if I can reproduce the report. Are you serving
          > this page in SSL? Your setForm arguments suggests this to be the case:
          > * YAHOO.util.Connect.setForm(sFormID, bFileUpload, true);
          >
          > If not serving SSL, what happens in IE when you remove the third
          > argument from setForm()?

          Thomas...

          That was from testing. No I'm not using SSL, and it does not work with
          or without the third parameter. ;-P

          I'm currently trying to use the debug version of Connection, so I'll
          report if I find anything via that route.

          Just in case, here's my form:

          <form name="frmUploadImage" id="frmUploadImage"
          action="javascript:niente();">
          <input type="hidden" name="ImageGroupCode" id="ImageGroupCode"
          value="0" runat="server" />
          <label class="lblFrmText2">Front:</label>
          <input type="file" name="FrontImage" id="FrontImage"
          class="frmInputText1" runat="server" />
          <br clear="all"/>
          <label class="lblFrmText2">Back:</label>
          <input type="file" name="BackImage" id="BackImage"
          class="frmInputText1" runat="server" />
          <br clear="all"/><br clear="all"/>
          <label class="lblFrmText2"> </label>
          <a href="javascript:ajPostForm('frmUploadImage',
          'CardImage')"><img src="/plastic/images/btn_Save_on.png" border="0"
          /></a>   <a
          href="javascript:layerOff('popup_ImageUpload')"><img
          src="/plastic/images/btn_Cancel_on.png" border="0" /></a>
          <br clear="all"/>
          </form>
        • Anthony Baratta
          OK - Here s more info... Looks like the error is with setForm. When I upload via FIreFox the following headers are set: CONTENT_LENGTH 50888 CONTENT_TYPE
          Message 4 of 12 , Sep 28, 2006
          • 0 Attachment
            OK - Here's more info...

            Looks like the error is with setForm. When I upload via FIreFox the
            following headers are set:

            CONTENT_LENGTH 50888
            CONTENT_TYPE multipart/form-data;
            boundary=---------------------------136132678524393

            With IE, I get:

            CONTENT_LENGTH 190
            CONTENT_TYPE application/x-www-form-urlencoded

            This leads me to start investigating the setForm Method not setting
            the isUpload correctly, or with the actual upload function somehow
            ignoring the isUpload variable.

            I'll keep digging. If anyone else comes up with other ideas or
            pointers, please let me know.
          • Thomas S. Sha
            ... You shouldn t be seeing this header application/x-www-form-urlencoded at all with a form submit. A form submit POSTs to an iframe and exits
            Message 5 of 12 , Sep 28, 2006
            • 0 Attachment
              --- In ydn-javascript@yahoogroups.com, "Anthony Baratta"
              <a.baratta@...> wrote:
              >
              > OK - Here's more info...
              >
              > Looks like the error is with setForm. When I upload via FIreFox the
              > following headers are set:
              >
              > CONTENT_LENGTH 50888
              > CONTENT_TYPE multipart/form-data;
              > boundary=---------------------------136132678524393
              >
              > With IE, I get:
              >
              > CONTENT_LENGTH 190
              > CONTENT_TYPE application/x-www-form-urlencoded

              You shouldn't be seeing this header
              "application/x-www-form-urlencoded" at all with a form submit. A form
              submit POSTs to an iframe and exits asyncRequest() before the header
              is set.

              So, is case "CardImage" being met and bFileUpload set to true for IE?

              Regards,
              Thomas

              Regards,
              thomas
            • Anthony Baratta
              OK - I m offically flumoxed. I ve gone through the code and do not see any errors. But for some reason IE is ignoring: (~703) this._formNode.enctype =
              Message 6 of 12 , Sep 28, 2006
              • 0 Attachment
                OK - I'm offically flumoxed.

                I've gone through the code and do not see any errors. But for some
                reason IE is ignoring:

                (~703) this._formNode.enctype = 'multipart/form-data';

                Strangely, if I manually set the enctype, it works! That's what I'm
                going to do moving forward - but maybe someone with better mad skillz
                than I can track down why IE is ignoring that setting.

                I checked the security settings and the website I'm working with is
                "trusted" and has the lowest security setting available.

                Weird.
              • Anthony Baratta
                ... Yes. I triple checked that. See last post - but I walked the whole execution path and the Connection Manager is setting all the object properties
                Message 7 of 12 , Sep 28, 2006
                • 0 Attachment
                  --- In ydn-javascript@yahoogroups.com, "Thomas S. Sha" <tsha@...> wrote:
                  >
                  > You shouldn't be seeing this header
                  > "application/x-www-form-urlencoded" at all with a form submit. A form
                  > submit POSTs to an iframe and exits asyncRequest() before the header
                  > is set.
                  >
                  > So, is case "CardImage" being met and bFileUpload set to true for IE?

                  Yes. I triple checked that.

                  See last post - but I walked the whole execution path and the
                  Connection Manager is setting all the object properties correctly. But
                  IE for some reason is ignoring the setting for enctype.

                  If I manually set the enctype for the target form (which will only
                  upload files - no dual use) then the file upload works.
                • Thomas S. Sha
                  ... My response was a bit misleading -- let me clarify. A form submission that includes file uploading will use an iframe, and does not set this header. A
                  Message 8 of 12 , Sep 28, 2006
                  • 0 Attachment
                    --- In ydn-javascript@yahoogroups.com, "Thomas S. Sha" <tsha@...> wrote:
                    >
                    > --- In ydn-javascript@yahoogroups.com, "Anthony Baratta"
                    > <a.baratta@> wrote:
                    > >
                    > > OK - Here's more info...
                    > >
                    > > Looks like the error is with setForm. When I upload via FIreFox the
                    > > following headers are set:
                    > >
                    > > CONTENT_LENGTH 50888
                    > > CONTENT_TYPE multipart/form-data;
                    > > boundary=---------------------------136132678524393
                    > >
                    > > With IE, I get:
                    > >
                    > > CONTENT_LENGTH 190
                    > > CONTENT_TYPE application/x-www-form-urlencoded
                    >
                    > You shouldn't be seeing this header
                    > "application/x-www-form-urlencoded" at all with a form submit. A

                    My response was a bit misleading -- let me clarify. A form submission
                    that includes file uploading will use an iframe, and does not set this
                    header. A non-file upload, form POST submission will contain the
                    "application/x-www-form-urlencoded" header.

                    Regards,
                    Thomas
                  • Thomas S. Sha
                    ... I can confirmed your report for IE. Per MSDN, IE6 supports enctype as a form property via scripting. However, not only doesn t this._formNode.enctype =
                    Message 9 of 12 , Sep 28, 2006
                    • 0 Attachment
                      --- In ydn-javascript@yahoogroups.com, "Anthony Baratta"
                      <a.baratta@...> wrote:
                      > See last post - but I walked the whole execution path and the
                      > Connection Manager is setting all the object properties correctly. But
                      > IE for some reason is ignoring the setting for enctype.
                      >
                      > If I manually set the enctype for the target form (which will only
                      > upload files - no dual use) then the file upload works.

                      I can confirmed your report for IE.

                      Per MSDN, IE6 supports enctype as a form property via scripting.
                      However, not only doesn't this._formNode.enctype =
                      "multipart/form-data" set properly, setAttribute doesn't as well.
                      You're seeing "application/x-www-form-urlencoded" because that's the
                      default value of the property.

                      However, this._formNode.encoding = "multipart/form-data"; does work
                      for IE6.

                      So you have two possible solutions:
                      * Include the enctype attrbute/value in your markup -- a
                      degradation-friendly strategy.
                      * Modify the property value assignment in connection.js to account for
                      IE and use property encoding. This will be refactored in connection
                      manager for the 0.12.0 release.

                      Regards,
                      Thomas
                    • Anthony Baratta
                      ... Cool! I guess I ll have to use other situations to confirm or deny I m going crazy. ;-) Strange that I m the first one to run into this. Anywho - Glad you
                      Message 10 of 12 , Sep 29, 2006
                      • 0 Attachment
                        --- In ydn-javascript@yahoogroups.com, "Thomas S. Sha" <tsha@...> wrote:
                        >
                        > I can confirmed your report for IE.
                        >

                        Cool! I guess I'll have to use other situations to confirm or deny I'm
                        going crazy. ;-)

                        Strange that I'm the first one to run into this. Anywho - Glad you are
                        on the ball and the software will be updated for the IE specific call.

                        Thanks for all the help!
                      • Anthony Baratta
                        Just for the sake of completeness, and in the gap between the next release, he s how I patched Connection Manager to fix the EncType issue with IE. Replace
                        Message 11 of 12 , Oct 2, 2006
                        • 0 Attachment
                          Just for the sake of completeness, and in the gap between the next
                          release, he's how I patched Connection Manager to fix the EncType
                          issue with IE.

                          Replace Line 703,
                          this._formNode.enctype = 'multipart/form-data';

                          with this:

                          if (this._formNode.encoding)
                          {
                          this._formNode.encoding = 'multipart/form-data';
                          } else {
                          this._formNode.enctype = 'multipart/form-data';
                          }

                          Works both in Firefox and IE, both on Windows. I did not test with
                          Safari or Opera.
                        • randomjuju
                          Hi there! I just wanted to chime in and say me too. I had the same problem, and was very glad to see this fix. I d also suggest that you can simplify the
                          Message 12 of 12 , Nov 1, 2006
                          • 0 Attachment
                            Hi there!

                            I just wanted to chime in and say "me too." I had the same problem,
                            and was very glad to see this fix. I'd also suggest that you can
                            simplify the patch down to just this:

                            this._formNode.enctype = 'multipart/form-data';
                            this._formNode.encoding = 'multipart/form-data';

                            Setting the extra attribute does no harm.

                            Thanks again for figuring this out -- I look forward to seeing it
                            fixed in the next release!

                            -Jon

                            --- In ydn-javascript@yahoogroups.com, "Anthony Baratta"
                            <a.baratta@...> wrote:
                            >
                            > Just for the sake of completeness, and in the gap between the next
                            > release, he's how I patched Connection Manager to fix the EncType
                            > issue with IE.
                            >
                            > Replace Line 703,
                            > this._formNode.enctype = 'multipart/form-data';
                            >
                            > with this:
                            >
                            > if (this._formNode.encoding)
                            > {
                            > this._formNode.encoding = 'multipart/form-data';
                            > } else {
                            > this._formNode.enctype = 'multipart/form-data';
                            > }
                            >
                            > Works both in Firefox and IE, both on Windows. I did not test with
                            > Safari or Opera.
                            >
                          Your message has been successfully submitted and would be delivered to recipients shortly.