• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Uploading image to a webserver

Sure,
The first thing you will need is somewhere on the web to store the image. Easiest thing to do here is go out and purchase a web hosting account from a provider such as Bluehost or HostGator, etc...

Next, you will need to create a servlet to run on the server and receive the image file from the client and place it on the server. For this, you can use Java, Python, etc...

Lastly, you will need to use the DefaultHttpClient class to connect to your servlet and send the image data via an outputstream.

Another option if you don't necessarily like or know how to work with servlets is to use a 3rd Party FTP library to upload the image via FTP.
 
Upvote 0
& a minor detail though to add to @jonbonazza's point, with http i.e DefaultHttpClient or UrlConnection or any other HTTP protocol you'll have to use multi-part form data to upload the file. As an alternative you can use sockets to just send it as binary stream, but if your users are behind firewall, proxy etc. ports other than 80 (HTTP) are most likely blocked.
 
  • Like
Reactions: adcosoft
Upvote 0
Thanks for help. I have successfully ran the application. I have used UrlConnection and multi part form data like you suggested. It was not so easy since I was creating for Android 2.1 compatible devices.

Congratulations :D

& trust me I understand multi-part form data with UrlConnection on 2.1 device -- i've known it first hand :rolleyes: if something goes wrong in future pay special attention to headers you're sending across and exact spacing, naming of multi-part fields

Good luck to you on your app
 
  • Like
Reactions: adcosoft
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones