Загрузите и отредактируйте изображение на сервере, используя API-интерфейс codeIgniter в React Native. - PullRequest
1 голос
/ 17 марта 2020

after edit image data

after called api, image not inserted

не может загрузить изображения из собственного кода кода на PHP сервер codeIgniter, Однако изображения загружаются без проблем с помощью почтальона. Другие данные доступны для редактирования, но изображение не загружается из собственного приложения реагирования. Поэтому, пожалуйста, не могли бы вы сказать мне, где именно проблема.

import React from "react";
import ProgressLoader from "../components/ProgressLoader";
import ImagePicker from "react-native-image-picker";

export default class ProfileContainer extends React.PureComponent {
  constructor(props) {
    super(props);
  }
  updateProfile() {
        const data = new FormData();
        data.append("user_id", parseInt(userObj.UserID) || 0);
        if (
          this.state.ImageSource != undefined &&
          this.state.ImageSource != null &&
          this.state.ImageSource != "" 

        ) {
          const fileType = "jpg";
          data.append("image",JSON.stringify({
            uri: this.state.ImageSource,
            name: `testPhotoName.${fileType}`,
            type: `image/${fileType}`
          }));
        }
        data.append("token", userObj.PhoneNumber);
        data.append("first_name", "" + this.state.firstName);
        data.append("last_name", "" + this.state.lastName);
        data.append("password", "1234");
        data.append("notification", this.state.isNotification ? "1" : "0");


        alert("with edit Profile Data------>"+JSON.stringify(data));

        fetch('http://freshnme.shreeduttply.com/v1/api/editProfile', {
            method: 'POST',
            headers: {
              'Accept': 'application/json',
              'Content-Type': 'multipart/form-data'
            },
            body: data })
          .then((response) => response.json())
          .then((responseJson) => {
              alert("After Called Api response:  " + JSON.stringify(responseJson));
          })
          .catch((error) => {
              console.error(error);
          });```
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...