How to upload image to php server through multipart request???

2,001 views
Skip to first unread message

N D Praveen

unread,
Mar 22, 2018, 1:13:17 AM3/22/18
to Flutter Dev
I am unable to send image in image format to php server.. i tried using base64 image but i want to upload as image format..... Any suggestions!!!!!!!!

Greg Spencer

unread,
Mar 22, 2018, 11:26:57 AM3/22/18
to N D Praveen, Flutter Dev
Hi Durga,

I'm not sure how your question relates to Flutter: are you trying to upload an image using a Flutter API and it's not working?

We'd probably need to know more details about what you're trying to do before we can help you: what classes/methods are you using to send the image, how did you create/load the image, etc.

We're not really PHP experts, so if the problem is on that side, you're probably better off asking on a PHP list.

-Greg.

On Wed, Mar 21, 2018 at 10:13 PM N D Praveen <durgapr...@terralogic.com> wrote:
I am unable to send image in image format to php server.. i tried using base64 image but i want to upload as image format..... Any suggestions!!!!!!!!

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Seth Ladd

unread,
Mar 22, 2018, 11:38:56 AM3/22/18
to Greg Spencer, N D Praveen, Flutter Dev
Thanks for reaching out!

Sounds like you want to submit an HTTP POST, containing binary data as the body.

I haven't tried this, but I think you can try something like this:

var httpClient = new HttpClient();
var request = await httpClient.postUrl(Uri.parse('http://your.server/upload.php'));
request.headers.contentType = new ContentType("image", "jpeg");  // or whatever MIME type for your image
request.add( ***a List<int> of the data for your image*** );
var response = await request.close();

You can read more at these API docs:



If you have further issues, we can recommend Stack Overflow as a really good place to post these kinds of "HOWTO" questions.

Hope that helps!

N D Praveen

unread,
Mar 28, 2018, 6:09:10 AM3/28/18
to Seth Ladd, Greg Spencer, Flutter Dev
Hi,

Thing is i want to select image from camera or gallery and send it to server and want to display that selected image as display pic like whatsapp or fb etc...

but i am unable to send it in image format..i can send it in base64 version but for displaying it in particular image field i am facing difficulty...

i have used image picker package for it... can anyone help me to solve the issue...

Thanks in advance

On Thu, Mar 22, 2018 at 9:08 PM, Seth Ladd <seth...@google.com> wrote:
Thanks for reaching out!

Sounds like you want to submit an HTTP POST, containing binary data as the body.

I haven't tried this, but I think you can try something like this:

var httpClient = new HttpClient();
var request = await httpClient.postUrl(Uri.parse('http://your.server/upload.php'));
request.headers.contentType = new ContentType("image", "jpeg");  // or whatever MIME type for your image
request.add( ***a List<int> of the data for your image*** );
var response = await request.close();

You can read more at these API docs:



If you have further issues, we can recommend Stack Overflow as a really good place to post these kinds of "HOWTO" questions.

Hope that helps!
On Thu, Mar 22, 2018 at 8:26 AM 'Greg Spencer' via Flutter Dev <flutt...@googlegroups.com> wrote:
Hi Durga,

I'm not sure how your question relates to Flutter: are you trying to upload an image using a Flutter API and it's not working?

We'd probably need to know more details about what you're trying to do before we can help you: what classes/methods are you using to send the image, how did you create/load the image, etc.

We're not really PHP experts, so if the problem is on that side, you're probably better off asking on a PHP list.

-Greg.

On Wed, Mar 21, 2018 at 10:13 PM N D Praveen <durgapr...@terralogic.com> wrote:
I am unable to send image in image format to php server.. i tried using base64 image but i want to upload as image format..... Any suggestions!!!!!!!!

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.

Seth Ladd

unread,
Mar 28, 2018, 11:36:57 AM3/28/18
to N D Praveen, Greg Spencer, Flutter Dev
Hi,

Please create a Stack Overflow question (https://stackoverflow.com/tags/flutter) with your code and any error messages. We can assist you better when we see what error messages you encounter.

Thank you!

To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.

N D Praveen

unread,
Mar 29, 2018, 12:36:11 AM3/29/18
to Seth Ladd, Greg Spencer, Flutter Dev
Thank you, I will do that. 
Reply all
Reply to author
Forward
0 new messages