FAUN — Developer Community 🐾

We help developers learn and grow by keeping them up with what matters. 👉 www.faun.dev

Follow publication

Flutter: Upload Image to Server from Mobile

--

I’m here to explain how to upload the image to our own server from the mobile App.

For the Server, I’ll be using Flask and For mobile application development, I will be using Flutter.

So Let’s Get Started…

Basically, the server has to be set up first for implementing this. So let's create a server using flask

Create a python file and add this line of code.

So, basically, we are creating a route of /upload in our flask and when the post request comes it gets the image using request.files[‘image’] and saves the image in the local directory of our Laptop/Computer.

Run

python app.py

and I’m using localtunnel npm package to use the localhost in my mobile application.

Now lets build our mobile App in Flutter

Create a new Flutter Project add http and image_picker package in pubspec.yaml

Adding Package in pubspec.yaml

For Uploading to the server add this line of code in your button Pressed event and don’t forget to add your API Url.

So here Using Multipart we are sending the image to the server and in the header, it is necessary to add multipart/form-data.

Overall main.dart code

Outputs of the mobile Application

After Selecting the Image

After Uploading an image to Server

Saved Image in my server i.e in my Computer

Here are the outputs which print on your console in your Server-side code.

You can check out the source code in my GitHub repository.

Join FAUN: Website 💻|Podcast 🎙️|Twitter 🐦|Facebook 👥|Instagram 📷|Facebook Group 🗣️|Linkedin Group 💬| Slack 📱|Cloud Native News 📰|More.

If this post was helpful, please click the clap 👏 button below a few times to show your support for the author 👇

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Published in FAUN — Developer Community 🐾

We help developers learn and grow by keeping them up with what matters. 👉 www.faun.dev

Written by Agnel Selvan

A person who is learning Flutter Development, Shaders, OpenGL, and Augmented Reality.

Responses (1)

Write a response