Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploading a o.File through o.XMLHttpRequest does not work in IE9 #28

Closed
cburgmer opened this issue May 21, 2013 · 2 comments
Closed

Uploading a o.File through o.XMLHttpRequest does not work in IE9 #28

cburgmer opened this issue May 21, 2013 · 2 comments

Comments

@cburgmer
Copy link

While the following example works well in Chrome, an unspecified error event is returned in IE9.

How to reproduce:
Open the page in the browser and click on "The button" and select a file. Output is logged to the console.

<!DOCTYPE HTML>
<html>
<head>
    <meta charset='utf-8'/>
    <script type="text/javascript" src="lib/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="lib/moxie.js"></script>
    <script>
    $(function () {
        var ajax = function (method, url, data, successCallback, errorCallback) {
            var ajaxRequest = new mOxie.XMLHttpRequest();
            ajaxRequest.onload = function () {
                if (ajaxRequest.status === 200 || ajaxRequest.status === 0) {
                    successCallback(ajaxRequest.response);
                } else {
                    errorCallback(ajaxRequest.status);
                }
            };

            ajaxRequest.onerror = function (e) {
                errorCallback(e);
            };

            ajaxRequest.open(method, url, true);
            ajaxRequest.setRequestHeader('Content-Type', 'application/octet-stream');
            ajaxRequest.send(data, {
                swf_url: "lib/Moxie.min.swf"
            });
        };

        fileInput = new mOxie.FileInput({
            browse_button: "button",
            swf_url: "lib/Moxie.min.swf"
        });
        fileInput.onchange = function (e) {
            console.log("change", e.target.files[0]);

            ajax("put", "/something", e.target.files[0].getSource(), function () {
                console.log("success");
            }, function (e) {
                console.log("error", JSON.stringify(e));
            });
        };
        fileInput.init();
    });
    </script>
</head>
<body>
    <div id="button">The button</div>
</body>
</html>
@cburgmer
Copy link
Author

If it helps, here's the example on http://jsfiddle.net/cburgmer/nDM98/. However IE9 complains about a wrong mime type for moxie.js and hence the example doesn't work there.

@cburgmer
Copy link
Author

This seems to work if I use e.target.files[0] instead of e.target.files[0].getSource() (see #29).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant