ZLSwipeableView icon indicating copy to clipboard operation
ZLSwipeableView copied to clipboard

unable to upload image on server using axios in react native

Open waqasarshad opened this issue 2 years ago • 1 comments

i am trying to upload a image with my other text data to server. but text data is uploading but image never uploads. here is my code

const fileToUpload = selectedImage1;
      const data = new FormData();
      data.append('image', 'Image Upload');
      data.append('file_attachment', fileToUpload);

    fetch('URL', {
    method: 'POST',
    headers: {
      Accept: 'application/json',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      first_name: textInputFname,
      last_name: textInputLname,
      email: textInputEmail,
      password: textInputPassword,
      phone: textInputPhone,
      address: textInputAddress,
      type: checked=='first'?1:2,
      company_name: textInputCoName,
      company_address: textInputCoAddress,
      company_tax_number: textInputCoTaxNum,
      extra_info: textInputExtraInfo,
      image: data
      })
  }).then((response) => response.json())

waqasarshad avatar Oct 31 '23 07:10 waqasarshad

selectedImage1 is the image path that i selected from image picker.

waqasarshad avatar Oct 31 '23 07:10 waqasarshad