Broken in IE9, Works Elsewhere
We've used for some years a home-grown file uploader for our classic ASP website. It works like this:
Issue is: this has worked fine for some years on various browsers, IE 6 to 8, Firefox and Opera. However, in IE9, the file upload does not work. The other popup-based tasks such as file renaming and directory creation continue to work.
Code - the file rename popup (works in IE9 and all before):
<html>
<head>
<title>Rename</title>
<link rel="stylesheet" href="/Common/CSS/screen.css" type="text/css" media="screen" />
</head>
<body>
<h1>Rename</h1>
<p>Enter the new name for "Config Mgmt Text.txt" in the folder "General/Share-Files/":</p>
<form name="form" method="post" action="/General/Share-Files.asp" encType="multipart/form-data" target="Browse-Files" onSubmit="self.setTimeout('window.close()', 500)">
<input name="task" type="hidden" value="T03" />
<input name="path" type="hidden" value="General/Share-Files/" />
<input name="target" type="hidden" value="Config Mgmt Text.txt" />
<input name="name" type="text" tabindex="1" size="40" value="Config Mgmt Text.txt"></input>
<input name="submit" type="submit" value="Rename" tabindex="2" />
</form>
</body>
</html>
Code - the file upload popup (broken in IE9, works in all before):
<html>
<head>
<title>Add Files</title>
<link rel="stylesheet" href="/Common/CSS/screen.css" type="text/css" media="screen" />
</head>
<body>
<h1>Add Files</h1>
<p>Browse for files to add to the folder "General/Share-Files/":</p>
<form name="form" method="post" action="/General/Share-Files.asp" encType="multipart/form-data" target="Browse-Files" onSubmit="self.setTimeout('window.close()', 500)">
<input name="task" type="hidden" value="T01" />
<input name="path" type="hidden" value="General/Share-Files/" />
<input name="file1" type="file" tabindex="1" size="40"></input><br />
<input name="file2" type="file" tabindex="2" size="40"></input><br />
<input name="file3" type="file" tabindex="3" size="40"></input><br />
<input name="file4" type="file" tabindex="4" size="40"></input><br />
<input name="file5" type="file" tabindex="5" size="40"></input><br />
<input name="submit" type="submit" value="Upload Files" tabindex="6" />
</form>
<p>Note that upload speed depends on your internet connection speed.</p>
</body>
</html>
All the forms are encType="multipart/form-data"
to accomodate the file upload, and the ASP on the main page does a Request.BinaryRead(Request.TotalBytes)
first thing with the form data. It then parses the data by delimiter, splitting it out into binary data (uploaded files) and text data (regular form fields). One of these regular form fields, <input name="task" type="hidden" value="T01" />
, is how it knows what to do with the submitted data (rename a file, upload a file, etc).
So, why does uploading, and only uploading, not work in IE9?
As above, the form submit method is the same for uploading and other (working) form actions, as is the server-side parsing of HTTP POST.
Debugging has shown that the file upload popup never even submits data back to the parent page (or to itself), iethe form data is never submitted to the server in the first place. But, all the other forms work the same way and do submit.....
Could this be something completely unrelated to code, like an IE9 security setting?
Have even tried forcing IE8 compatability mode on IE9 ( <meta http-equiv="X-UA-Compatible" content="IE=8" >
), no change.
Any assistance greatly appreciated.
Thanks
Lukas
Update:
1) "Doesn't work" means that the upload popup dissapears on submit (as it should), but nothing is ever submitted to the parent page. If I disable the auto-close on the popup: after clicking submit the text fields containing the path(s) to the file(s) to be uploaded are cleared, but nothing else happens. This suggests that it is submitting to the popup page rather than the parent page, but that doesn't really make sense, as the other (working under IE9) popup pages still correctly submit to the parent page. I'll try replacing the JS-generated popup page with a conventional ASP page that can show any HTTP POST data, and go from there.
2) If I force compatability mode on the client side (IE9 compatability view button), it does work exactly as it should. This is more workaround than fix though. I suppose it does rule out browser settings though, as compatability mode would only affect page rendering?
I was able to solve this issue in Windows7 & IE9 (worked in all other browsers and versions I could test) by making sure the first attribute of the initiating window.open() call had a viable url in it.
I was actually write() 'ing to the opened window to stick the code in it that I wanted, which included the file upload form. So I didn't have a url I needed to declare on the opened window. It said "about:blank" in the address bar. Further, by hitting F12 in the window, I could see I was getting a "SCRIPT5: Access is denied" error when I tried to submit the form.
I was calling the popup window like this:
var popup_window = window.open("","upload_popup_window_name","menubar=1,resizable=1,scrollbars=1,width=630,height=400");
By changing the above to:
var popup_window = window.open("/blank.html","upload_popup_window_name","menubar=1,resizable=1,scrollbars=1,width=630,height=400");
Where /blank.html was an actual file that the web server returned a 200 code upon the request(although it could actually be the source of the url you wanted to call, I'm assuming if you had already done it this way, it would work).
I still overwrote the contents of the window by by document.write()'ing all my own code into the window they way I was previously doing anyways.
By making this small modification, IE9 then allowed file uploads to be INITIATED by the popup window and I no longer received the "SCRIPT5: Access is denied" error. And files began to be successfully uploaded again.
Hope that helps
Is ie 9 case sensitive to your form attributes?
try changing:
encType="multipart/form-data"
to:
enctype="multipart/form-data"
and clear your cache.
链接地址: http://www.djcxy.com/p/36522.html上一篇: $(#id).className jQuery不能在IE9中工作
下一篇: 在IE9中破坏,在其他地方工作