We successfully set up image uploading on our server with nginx. Everything gets posted to /upload and then redirects to /file for processing. The file gets uploaded and stored, but there are headers at the top of the file.
------WebKitFormBoundaryqUwBABts5uiLHgDN
Content-Disposition: form-data; name="picture"; filename="coldplay.jpg"
Content-Type: image/jpeg
What am I to do with this? Do I strip these headers out with PHP and then save the file again?
Is uploading files with these headers expected behavior?
Here is the form:
<form action="/upload/" id="upload3" method="post">
<input type="file" id="file" name="picture" value=""/>
<input type="submit" onclick="return uploadFiles(this.form);">
</form>
and js:
<script type="text/javascript">
function uploadFiles(form) {
var formData = new FormData(form);
var url = "/upload/";
var xhr = new XMLHttpRequest();
xhr.open('POST', url, true);
xhr.onload = function(e) {
if (this.status == 200) {
console.log(this.responseText);
}
};
xhr.send(formData); // multipart/form-data
return false;
}
</script>