There are differences between IE and Firefox on the form enctype attribute.In general, for dynamically created forms, if you want to upload files, you will naturally useCode:
1 // Create form
2 This . Form = Document. createelement ( " Form " );
3 This . Form. ID = " Jasonuploadform " ;
4 This . Form. Name = " Jasonuploadform " ;
5 This . Form. Method = " Post " ;
6 This . Form. Action = Actiontarget;
7 This . Form. enctype = " Multipart/form-Data " ;
8 Document. Body. appendchild ( This . Form );
This Code does not seem to be a problem on the surface, but it still cannot change the form encoding format in IE,
That is to say, the contenttype uploaded to the server is still: "application/X-WWW-form-urlencoded ".
But it can be correctly identified in Firefox, so that files can be uploaded normally.
So how can we make IE and Firefox correctly encode form data according to our requirements? After finding N for a long time, I finally found the solution, that is, simply specifying encoding and reading the following correct code:
1 // Create form
2 This . Form = Document. createelement ( " Form " );
3 This . Form. ID = " Jasonuploadform " ;
4 This . Form. Name = " Jasonuploadform " ;
5 This . Form. Method = " Post " ;
6 This . Form. Action = Actiontarget;
7
8 // This. Form. setattribute ("enctype", "multipart/form-Data ");
9 This . Form. Encoding = " Multipart/form-Data " ;
10
11 Document. Body. appendchild ( This . Form );