RN多文件上传
来源:互联网 发布:软件英文怎么写 编辑:程序博客网 时间:2024/05/02 04:38
/* * * 上传图片请求 * @param * @returns * */ uploadImage(imgAry) { let formData = new FormData();<br> //因为需要上传多张图片,所以需要遍历数组,把图片的路径数组放入formData中 for(var i = 0;i<imgAry.length;i++){ let file = {uri: imgAry[i], type: 'multipart/form-data', name: 'image.png'}; //这里的key(uri和type和name)不能改变, formData.append("files",file); //这里的files就是后台需要的key } fetch('http://192.168.0.183:8080/whale/test/upload_files',{ method:'POST', headers:{ 'Content-Type':'multipart/form-data', }, body:formData, }) .then((response) => response.text() ) .then((responseData)=>{ console.log('responseData',responseData); }) .catch((error)=>{console.error('error',error)}); }
其中,关于图片的路径,我的是这样的:
iOS:
file:///Users/shaotingzhou/Library/Developer/CoreSimulator/Devices/9462ED30-88C7-4318-BF83-3914B9314D34/data/Containers/Data/Application/E9A05CAF-AF07-4BA3-B2C3-C2EFBC6C2C6A/Documents/images/D5E1640B-836A-4EC9-A5C2-65B2E4E8CFE0.jpg
Android:
file:///storage/emulated/0/Pictures/image-ec0667ed-ecc5-4eed-928f-26fed6a63860.jpg
0 0
- RN多文件上传
- RN
- RN
- RN
- RN
- 文件上传(多文件)
- RN 多行换行布局
- asp.net文件上传,多文件上传。
- 单文件上传、多文件上传
- struts2文件上传与多文件上传
- 单文件上传和多文件上传
- PHP文件上传功能 -- 多文件上传
- struts2文件上传(多文件上传)
- SpringMVC文件上传 多文件上传实例
- Struts2之文件上传,多文件上传
- SpringMVC文件上传 多文件上传实例
- 文件上传及多文件上传
- Spring boot 文件上传(多文件上传)
- 各种问题!!!
- cs231n assignment1--svm
- 16蓝桥杯--JAVA语言C组-第10题-密码脱落
- Coreseek Windows下安装调试
- LSTM
- RN多文件上传
- 网易2017年秋招编程题之暗黑的字符串
- 统计时,时间格式如何获取
- 高通平台修改LK(bootloader)开机logo
- noi-7805-配对碱基链
- phpMyAdmin中sql-parser组件的使用
- iOS对象属性详解
- Cloud云深商学院内部频道剪辑上篇-社会大学
- 整数分解为若干项之和