简体   繁体   中英

send image array for fetch formData in react-native

With the console.log I can see the array imagenes and this is ok in proyect react-native, but on the server this variable does not arrive but if I get the array of dates and the variable description on the server

 let body = new FormData(); body.append('descripcion', 'dsadsadsa'); body.append('fechas[]', '2018-05-05'); body.append('fechas[]', '2015-05-05'); const {page1, page2, page3, page4, page5} = this.props.items; body.append('imagenes[]', { uri: page2[2], name:'photo1.jpg', type: 'image/jpg'}); body.append('imagenes[]', { uri: page2[3], name:'photo2.jpg', type: 'image/jpg'}); body.append('imagenes[]', { uri: page2[4], name:'photo3.jpg', type: 'image/jpg'}); fetch(url, { method: 'post', headers: { 'Accept': 'application/json', 'Content-Type': 'multipart/form-data' }, body: body }) .then(res => res.text()) .then(res => { console.log(res) }).catch((err) => { console.log('err', err) }); }); 

Thanks for help me!

the code upload data and file (images) in RN this is ok, the bug in vars size file php.ini (memory_limit, upload_max_filesize, post_max_size).

in nginx, edit file nginx.conf add or update command

client_max_body_size 500M

Link https://www.cyberciti.biz/faq/linux-unix-bsd-nginx-413-request-entity-too-large/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM