Laravel REST API图像上传在React Native App中
我可以使用Laravel Rest API上传图像,但是
我正在使用 react-native-image-picker
这是图像拾取器的响应
LOG FileName : {"fileName": "rn_image_picker_lib_temp_ff6cf0af-08b3-41ff-8f76-81a744d42ad4.jpg",
"fileSize": 37514, "height": 2400, "type": "image/jpeg",
"uri": "file:///data/user/0/com.hometutorsclub/cache/rn_image_picker_lib_temp_ff6cf0af-08b3-41ff-8f76-81a744d42ad4.jpg", "width": 1080}
,使用此方法上传
var data = new FormData();
data.append('img', {
uri : imageObj.uri,
type: imageObj.type,
name: imageObj.fileName,
});
此处是API配置上传图像
使用此配置,映像正正确地上传到邮递员上,但是在React Native App不上传
我认为frontend和后端config notect通信上传
您能帮我帮助我。
I what to upload image using Laravel rest API, but there is some issue
i am using react-native-image-picker
here is the response of image picker
LOG FileName : {"fileName": "rn_image_picker_lib_temp_ff6cf0af-08b3-41ff-8f76-81a744d42ad4.jpg",
"fileSize": 37514, "height": 2400, "type": "image/jpeg",
"uri": "file:///data/user/0/com.hometutorsclub/cache/rn_image_picker_lib_temp_ff6cf0af-08b3-41ff-8f76-81a744d42ad4.jpg", "width": 1080}
and using this method to upload
var data = new FormData();
data.append('img', {
uri : imageObj.uri,
type: imageObj.type,
name: imageObj.fileName,
});
here is API configuration to upload image
Laravel Rest API configuration of image upload
with this config, image is uploading properly on POSTMAN but in React Native app is not uploading
i think frontend and backend config not communicating to upload it
can you please help me where is the issue
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当它在邮递员上工作时,这可能是一个标题问题。
在使用Postman发送请求时,请查看隐藏的生成的标题,并找出您的React请求中错过的标题。
最有可能是一个内容类型的问题。上传图像时,我可以在邮递员的标题中看到此标头:
As It's working on Postman, it may be a header issue.
While sending your request using Postman, take a look at the hidden generated headers and find out which one is missed in your react request.
Most likely, it is a Content-Type issue. I can see this header in my Postman headers while uploading an image: