问题
I'm using dropzone to upload files to my sails backend.
For the longest time, I have been unable to figure out why it isn't working. However, when I put the req object in the console.log, I got the following headers (i.e., this would be req.headers) :
headers:
{ 'x-id': 'vendor-______________',
'x-token': '_______________',
host: 'localhost:1337',
'content-type': 'application/x-www-form-urlencoded',
'content-length': '0',
connection: 'close'
},
I'm guessing this means that dropzone is missing something up, so that it is not sending the request with a content-type of multipart
Here's the dropzone code itself: (Note that it is closely related to the example given in the dropzone docs, but is part of a react component)
Component.add("DropzoneComponent", {
getDefaultProps: function(){
return {}
},
componentDidMount: function() {
var c = this
var field = new Dropzone(c.refs.dropzone, {
url: c.props.url,
paramName: "csv"
});
field.on("error", function(fileObject, err) {
console.log("dropzone file object:", fileObject, "***Error message***", err);
})
field.on("success", function(fileObject, file){
console.log("file object", fileObject, "file:", file);
})
render: function(){
return (
<span>
<input type="hidden" value={this.state.image || ""} name={this.props.name || ""} />
<div id="upload-field" ref="dropzone" type="file" className="dropzone"></div>
</span>
)
}
Any guesses on why would this would be, or if I am misdiagnosing the situation?
来源:https://stackoverflow.com/questions/44039671/dropzone-sending-a-request-with-application-x-www-form-urlencoded-as-the-conte