I'm trying to attach files to CouchDB documents when they are created.
This is the HTML code:
<form>
<input type="hidden" name="type" value="devtest"/>
<input type="file" name="_attachments" id="picture" accept="image/*" multiple/>
<button type="submit">Go</button>
</form>
This is the JS code handling the upload
$(document).on('submit', 'form', function(e) {
e.preventDefault();
var formdata = $(this).serializeObject(); // Provided by a pluign
$(this).find(':file').each(function(k,v) {
formdata[$(this).attr('name')] = $(this).val(); // Treating files
});
// Using the kanso db package
m.db.current().saveDoc(
formdata,
function(err,res) {
console.log('gna');
});
});
This produces the following error 500 message:
{"error":"doc_validation","reason":"Bad special document member: _attachments"}
I'm using CouchDB 1.3.1 with kanso 0.2.2 and db 0.1.0.