HTML:
<input type="file" v-model="fileName" @change="fileNameChange" />
的javascript:
fileNameChange(e) {
const file = e.target.files[0]
console.log('this.fileName', file)
let reader = new FileReader()
reader.onload = (e) => {
let path = `db/${this.doc._id}/${file.name}?rev=${this.doc._rev}`
console.log('imgdata', e, e.target.result, reader.result)
$.ajax(path, {
type: 'PUT',
contentType: file.type,
data: reader.result, //e.target.result,
processData: true,
success(resp) {
console.log(resp)
utils.notify('file is uploaded succesfully')
},
error(err) { console.log(err) },
})
};
reader.readAsArrayBuffer(file)
}
此代码有效,我看到文件已成功上传&#39;消息,但在CouchDB文档中,我看到0字节长度附件:
1.jpg 0 bytes, image/jpeg
我该如何解决这个问题?
答案 0 :(得分:1)
我找到了解决方案。如果将一个字符串从
renderLastSlide(index) {
if (index === this.props.data.length - 1) {
return (
<Container>
<Content>
<Button
title= 'hai'
onPress={this.props.onComplete} // Add here
rounded
light
/>
</Content>
</Container>
);
}
更改为
processData: true,
所有工作正常