Carga de archivos en reaccionar nativo al servidor php
Estoy implementando la carga de archivos en react-native-ios. Aquí está mi código en react-native js:
const formData = new FormData();
formData.append('photo', { uri: image.sourceURL, name: image.filename, type: 'image/jpeg' });
// here is my formdata console :{uri: "file:///Users/.../DCIM/100APPLE/IMG_0002.JPG", name: "IMG_0002.JPG", type: "image/jpeg"}
fetch('services.php?action=MultiplefileUpload',{
method: 'POST',
headers: {
'Content-Type': 'multipart/form-data',
'Accept': 'application/json'
},
body: formData
}).then((response) => response.json())
.then((responseJson) => {
console.log(responseJson);
})
.catch((error) => {
console.error(error);
});
Y en la página php escribí:return $_FILES
La respuesta que viene es:photo: {name: "IMG_0002.JPG", type: "", tmp_name: "", error: 1, size: 0}
¿Dónde estoy haciendo mal aquí en mi código? También leo este enlace:Subir archivo de imagen al servidor php desde react-native