Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

241
Views
How to Upload Image File To server in react native

By selecting Image or File Gallery My data Look Like this

[{"fileCopyUri": "content://com.android.providers.media.documents/document/image%3A55539", "name": "c6235fa2-aa7f-4e06-a664-7e805de2f883.jpg", "size": 1967925, "type": "image/jpeg", "uri": "content://com.android.providers.media.documents/document/image%3A55539"}]

{"fileCopyUri": "content://com.android.providers.media.documents/document/document%3A55435", "name": "Maha Police-2019 222.pdf", "size": 302194, "type": "application/pdf", "uri": "content://com.android.providers.media.documents/document/document%3A55435"}

By Capturing Image from Camera My data look like this

{"assets": [{"fileName": "rn_image_picker_lib_temp_c96a3333-f53f-4143-af29-e0270c8e6a8c.jpg", "fileSize": 24925, "height": 550, "type": "image/jpeg", "uri": "file:///data/user/0/com.sanayaapp/cache/rn_image_picker_lib_temp_c96a3333-f53f-4143-af29-e0270c8e6a8c.jpg", "width": 247}]}

I am Sending Data through FormData like this


const formData = new FormData();


formData.append('SellerBrandsWeDeal', selectedFile);

fetch('http://api', {
          method: 'POST',
          headers: {Accept: '*/*', 'Content-Type': 'multipart/form-data'},
          body: formData,
})

But its keep saying network error. please help thanks

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

you can use rn-fetch-blob to code yours picture in base64 string , then you can send base64 string to server. Like this - React-Native: Convert image url to base64 string

about 4 years ago · Juan Pablo Isaza Report

0

You can create image object like this:

    selectedFile = {
                   uri:
"content://com.android.providers.media.documents/document/image%3A55539",
                    name: "c6235fa2-aa7f-4e06-a664-7e805de2f883.jpg",
                    type: "image/jpeg"
                     }
about 4 years ago · Juan Pablo Isaza Report

0

For me I convert the image to base64 and upload it to the data base as a blob. Here a function to convert it to base64 , all you need is to implement it . The result of the conversion it stored in image state .

const handleFile = (e) => {
let file = e.target.files[0];
getBase64(file)
  .then((result) => {
    // console.log("result",result)
    setImage({
      base64URL: result,
    });
  })
  .catch((err) => {
    setUploadFileError(err);
  });

};

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!