• 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

adcosoft

Lurker
hi,
I need to create an app which will upload image and some details to a web.
Does any one know how it can be done?
Thanks in advance.
 
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.
 
& 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.
 
Thanks jonbonazza and wubbzy for replies..
This application allows user to take photo and upload it to website along with some text descriptions..
I know java webservices and servlets programming. My main doubt is that does it need webservice or is servlets enough?
 
This application allows user to take photo and upload it to website along with some text descriptions..
I know java webservices and servlets programming. My main doubt is that does it need webservice or is servlets enough?

Always go small [least resistance route] first to test your theory
 
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.
 
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
 
Back
Top Bottom