Opened 11 years ago

Closed 11 years ago

#6098 closed defect (invalid)

IE 6.0 bug on: Change form enctype dynamically

Reported by: guest Owned by: dante
Priority: high Milestone:
Component: DojoX Widgets Version: 1.0
Keywords: Cc: carrie.zhxj@…
Blocked By: Blocking:

Description

widget/FileInputAuto.js

When _sendFile we should receive an existed form , instead of create a new form dynamically.


Recently, I found a bug on IE 6.0 about form enctype changing. As follow:

If the enctype of a form is not assign to "multipart/form-data" directly in HTML, we can not change it through Javascript. Also when we create a new form , cannot do it neither.

For example:

HTML is:

<form id='ie' method='post' action="ReceiveFile?.php" target="_blank">

<input type="file" name="dynamic1" /> <input type="submit" name="submit" value="submit"> </form>

Then:

document.getElementById("ie").enctype = "multipart/form-data";

OR

document.getElementById("ie").setAttribute("enctype","multipart/form-data");

Then we get the enctype attribute of that form, it is "multipart/form-data" indeed, but when you submit the form, IE 6.0 will use the default value for that attribute.

So in IE 6.0, we should write the form and enctype in HTML, instead of creating it dynamically in JavaScript?

Change History (6)

comment:1 Changed 11 years ago by guest

Reported by Carrie Zhang: carrie.zhxj@… Thanks 200803

comment:2 Changed 11 years ago by dante

I'm not sure I follow or agree. I have a branch in the FileInput? code that works around IE's jankyness by:

var _newForm; 
		if(dojo.isIE){
			// just to reiterate, IE is a steaming pile of code. 
			_newForm = document.createElement('<form enctype="multipart/form-data" method="post">');
			_newForm.encoding = "multipart/form-data";
			
		}else{
			// this is how all other sane browsers do it
			_newForm = document.createElement('form');
			_newForm.setAttribute("enctype","multipart/form-data");
		}

found in FileInputAuto?.js -- this is a documented and viable workaround. The normal file input does nothing regarding the form it lives it, it just acts as a semi-styled file input. If you use a FileInputAuto? within another form, if you passed that form, all the data in it would be sent with the request.

Are you asking for the ability to pass a form to use for the submission part? It's intentionally that way because the Auto version uses an iframe, which only allows for one concurrent transmission anyway, and the "regular" version just sits in an existing <form>, which you will have put the enctype on yourself anway?

comment:3 Changed 11 years ago by dante

Cc: carrie.zhxj@… added

comment:4 Changed 11 years ago by guest

oh, I got it, use

_newForm.encoding="multipart/form-data"

is okay for IE 6.0

Thanks, Carrie Zhang

comment:5 Changed 11 years ago by guest

but I think , bellow those code, should add

this.fileInput.setAttribute("name",this.name);

to set the name of INPUT file

Orelse, cannot post that file

comment:6 Changed 11 years ago by dante

Resolution: invalid
Status: newclosed

the name attribute is successfully set on the "real" file input by the template in both widgets as far as I can tell.

Unless I'm missing something, this is a support/enhancement discussion for a dojox component, and we should move it to the forums. :)

Note: See TracTickets for help on using tickets.