Skip to content
Advertisement

how to upload image on flutter to MySQL

I am a newbie in a flutter. Can someone show me how to upload an image to my MySQL? I can’t find any solution in the past weeks.

My Code:

JavaScript

my PHP code:

JavaScript

MySQL database:

enter image description here

It only uploaded my image path to the database. Please help me. I have understood that “image”: _image.path, this code is the result why my database is saving the image path instead of a photo. I am already trying to search using the path location and save the image to the htdoc file but does not work when I am uploading it. The image is nowhere can be found in the htdoc. please help me.

Advertisement

Answer

Check out answers to How to upload an image in Flutter? for more on uploading files from flutter. You will want to use a MultipartRequest from http library.

A google search should also show you how to save the file to MySQL, probably as a blob. It’s a whole topic on its own, you might end up saving the files to the filesystem and storing paths in the database.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement