File upload 302?
<p>I've finally gotten my asynchronous file upload working, except it only seems to handle text files. </p>

<p>If I upload a text file, it works and saves the file. If I upload an image, it fails firebug reports the response has a 302 status, and I get sent to the root directory of my public_html</p>

<p>I thought it may be related to file size, but doesn't seem to be the case, as I made the text file larger than the image, and it worked out. </p>

<p>I'm not sure where to start troubleshooting, I'll place the PHP relevant snippet below.</p>

<p><strong>PHP</strong></p>

<pre><code>$fn = (isset($_SERVER['HTTP_X_FILENAME']) ? $_SERVER['HTTP_X_FILENAME']:false);
echo $fn;

try{
    file_put_contents("upload/".$fn, file_get_contents("php://input"));
    //echo file_get_contents("upload/".$fn);
}catch(exception $e){
    echo $e-&gt;getMessage();
}
</code></pre>

<p><strong>JS</strong></p>

<pre><code>function UploadFile(file){
    var xhr = new XMLHttpRequest();
    //on the below if
    //xhr.upload: returns a XMLHttpRequestUpload Object, I believe just to check if it's supported in broswer
    if (xhr.upload){
        xhr.open("POST","http://domain.com/absolutepath/what.php",true);
        xhr.setRequestHeader("X-FILENAME",file.name);

        xhr.onreadystatechange = function(){
        if(xhr.status == 200 &amp;&amp; xhr.readyState == 4){
            callback(xhr.responseText);
        }
    }
    xhr.send(file);
    }else{
        alert("Sorry, don't think this is supported in your browser.");
    }
}
</code></pre>

<p>Is there a request header I should be setting? Is it something in php.ini I need to change? My max post size is I think 32MB, not sure what else would effect this. </p>