目前,我陷入了一个无法解决的问题,希望能对您有所帮助。
我制作了一个React Native应用程序,其中使用了react-native-image-picker
软件包将图像上传到服务器。
图像上传在android上工作正常,但是每当我尝试通过IOS模拟器上传图像时,应用程序都会关闭,并且控制台上不会生成任何错误。我想知道为什么会发生这种情况。
我正在通过表单向本地主机提交请求
这是我的代码
formdata.append('file', {
uri: imageResponse.uri,
name: fileName,
type: imageResponse.type
})
axios.post(url, formdata, {
headers: {
"Content-Type": "multipart/form-data"
}
}).then((response) => {
var dataObj = response.data;
newMessage[0].text = JSON.stringify(dataObj.data)
if(screenType == 'group') {
this.postGroupChat(newMessage, 2)
}else {
this.postChat(newMessage, 2)
}
})
.catch((error) => {
console.log(5555, error)
});