xmlhttprequest POST 405 - Method NOT ALLOWED
<p>I have a problem that is making me crazy because I'm not able to solve it. I want to upload with my application some files to a server IIS. </p>

<p>My code in HTML is: </p>

<pre><code>&lt;input id="files" type="file" /&gt;
</code></pre>

<p>And just in the controller when I detect that a new file is added I use XMLHttpRequest:</p>

<pre><code>document.getElementById('files').addEventListener('change', function (e) {
        var file = this.files[0];
        var xhr = new XMLHttpRequest();
        (xhr.upload || xhr).addEventListener('progress', function (e) {
            var done = e.position || e.loaded
            var total = e.totalSize || e.total;
            console.log('xhr progress: ' + Math.round(done / total * 100) + '%');
        });

        xhr.open('POST', 'http://10.0.19.25:80/CG/files', true);

        xhr.addEventListener('load', function (e) {
            console.log('xhr upload complete', e, this.responseText);
        });

       xhr.send(file);
    });
</code></pre>

<p>When I launch my app on Chrome, Firefox or IE, I get this error: </p>

<pre><code>POST http://10.0.19.25/CG/files 405 (Method Not Allowed)
</code></pre>

<p><a href="http://i.stack.imgur.com/6qs2I.png" rel="nofollow">enter image description here</a></p>

<p>Thanks in advance! </p>