By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,247 Members | 871 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,247 IT Pros & Developers. It's quick & easy.

IE Upload file problem

Canabeez
100+
P: 126
Hi all,

anyone has an idea why IE is not uploading file and FF does? I'm creating a FORM + IFRAME using DOM and trying to upload a file, now Firefox and Chrome do thins perfectly.

I have attached a Log from HTTPAnalyzer.

Anyhow, here's the code I'm running, Class File:
Expand|Select|Wrap|Line Numbers
  1. HTMLElement.Upload = function(Params)
  2. {
  3.     var FORM = new HTMLElement(HTMLElement.FORM,{
  4.         id:      'FO_'+Params.Id,
  5.         action:  Params.Handler,
  6.         method:  'post',
  7.         enctype: 'multipart/form-data',
  8.         target:  'FR_'+Params.Id
  9.     });
  10.     var IFRAME = new HTMLElement(HTMLElement.IFRAME,{
  11.         name:    'FR_'+Params.Id,
  12.         id:      'FR_'+Params.Id,
  13.         width:   0,
  14.         height:  0,
  15.         border:  0
  16.     });
  17.     IFRAME.name = 'FR_'+Params.Id;
  18.     IFRAME.style.display = 'none';
  19.     document.body.appendChild(IFRAME);
  20.  
  21.     if(!Params.MaxFileSize)
  22.     {
  23.         Params.MaxFileSize = 10485760;
  24.     }
  25.  
  26.     FORM.appendChild(new HTMLElement(HTMLElement.INPUT,{
  27.         type:  'hidden',
  28.         name:  'MAX_FILE_SIZE',
  29.         value: Params.MaxFileSize
  30.     }));
  31.  
  32.     if(Params.File)
  33.     {
  34.         FORM.appendChild(new HTMLElement(HTMLElement.INPUT,{
  35.             type: 'file',
  36.             name: Params.File,
  37.             id:   'FI_'+Params.Id,
  38.             onchange: function()
  39.             {
  40.                 document.getElementById('FR_'+this.id.substring(3)).onload = function()
  41.                 {
  42.                     if(document.getElementById('FO_'+this.id.substring(3)))
  43.                     {
  44.                         document.getElementById('FO_'+this.id.substring(3)).innerHTML = '<i>Done</i>';
  45.                     }
  46.                 };
  47.                 this.parentNode.submit();
  48.  
  49.                 var SPAN = new HTMLElement(HTMLElement.SPAN,{});
  50.                 SPAN.appendChild(new HTMLElement(HTMLElement.IMG,{
  51.                     src: HTMLElement.CONFIG.IMAGE_UPLOAD_LOADER.src,
  52.                     width: HTMLElement.CONFIG.IMAGE_UPLOAD_LOADER.width,
  53.                     height: HTMLElement.CONFIG.IMAGE_UPLOAD_LOADER.height
  54.                 }));
  55.                 SPAN.appendChild(new HTMLElement(HTMLElement.SPAN,{
  56.                     innerHTML: '&nbsp;Uploading file \"'+this.value+'\"...</i>'
  57.                 }));
  58.                 this.parentNode.innerHTML = SPAN.innerHTML;
  59.             }
  60.         }));
  61.     }
  62.     else if(Params.Files)
  63.     {
  64.         for(var i in Params.Files)
  65.         {
  66.             FORM.appendChild(new HTMLElement(HTMLElement.INPUT,{
  67.                 type: 'file',
  68.                 name: i
  69.             }));
  70.         }
  71.     }
  72.     return FORM;
  73. }
HTMLElement constructor:
Expand|Select|Wrap|Line Numbers
  1. function HTMLElement(aElement, Params)
  2. {
  3.     if((aElement == HTMLElement.IFRAME ||
  4.         aElement == HTMLElement.INPUT) &&
  5.             HTMLElement.ISIE)
  6.     {
  7.         var ParamsString = '';
  8.         if(Params.name)
  9.         {
  10.             ParamsString += ' name="'+Params.name+'"';
  11.         }
  12.         if(Params.type)
  13.         {
  14.             ParamsString += ' type="'+Params.type+'"';
  15.         }
  16.         var aElement = document.createElement('<'+aElement+ParamsString+'>');
  17.     }
  18.     else
  19.     {
  20.         var aElement = document.createElement(aElement);
  21.     }
  22.     for(var i in Params) aElement[i] = Params[i];
  23.     return aElement;
  24. }
And the code I run is:
Expand|Select|Wrap|Line Numbers
  1. window.onload = function(){
  2.     HTMLElement.onload = function()
  3.     {
  4.         HTMLElement.ConvertSelectsToDropdowns();
  5.         document.getElementById('vvv').appendChild(new HTMLElement.Upload({
  6.             Id: 'upl',
  7.             File: 'uploadedfile',
  8.             Handler: 'ESCMS_HTMLElement/upload.php'
  9.         }));
  10.     }
  11.     new HTMLElement.Include(HTMLElement.CLASS_BOX);
  12.     new HTMLElement.Include(HTMLElement.CLASS_DROPDOWN);
  13.     new HTMLElement.Include(HTMLElement.CLASS_AJAX);
  14.     new HTMLElement.Include(HTMLElement.CLASS_UPLOAD);
  15.  
  16. }
  17.  
Thanks in advance
Attached Files
File Type: zip Log.zip (1.56 MB, 94 views)
Jul 27 '09 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
I've not tested your code, but do you get any errors?

Here's one that should work.
Sep 5 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.