upload files from android to web Server

12 replies [Last post]
shadowdragon
User offline. Last seen 2 years 9 weeks ago. Offline
Joined: 11/20/2009

Hi to all, Sorry for the post in first page.

Can you any one tell me , how to upload file from android to web server.
Using following php code and android code, I can send data from android to web server. i don't know how to upload files.

php Code.

<?php

$target_path = basename( $_FILES["uploadedfile"]["name"]);
if(move_uploaded_file($_FILES["uploadedfile"]["tmp_name"], $target_path)) {
echo "The file ".basename( $_FILES["uploadedfile"]["name"])." has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
echo _POST('data'
}

android Code.

try
{
HttpClient client = new HttpClient();
HttpMethod method = new PostMethod("http://webserver.com/data.php?data=myData"

client.executeMethod(method);
a.setText("Ok"+method.getResponseBodyAsString());
method.releaseConnection();
}
catch (Exception e)
{
a.setText("Error"
}

Can you anyone help me to solve this problem.

Regards,
Venkat

?>

1xuntong
User offline. Last seen 5 weeks 6 days ago. Offline
Joined: 12/25/2011
miu miu

Golden cherubim prada tote bag 2012 the border of yellow, green hand wan xia ROM peony mist the yarn

Reverse Phone Lookup
User offline. Last seen 42 weeks 22 hours ago. Offline
Joined: 04/13/2011
Reverse Phone Lookup

Hi to All,
is it possible to upload files from android to web server, In web server i am using Php file to upload files.

This is sample php file to upload files to web server.

Syntax: [ Download ] [ Hide ] [ Select ] [ Expand ]
Syntax: [ Download ] [ Show ]
Using php Syntax Highlighting

1.
<?php
2.
$target_path = basename( $_FILES["uploadedfile"]["name"]);
3.
if(move_uploaded_file($_FILES["uploadedfile"]["tmp_name"], $target_path)) {
4.
echo "The file ".basename( $_FILES["uploadedfile"]["name"])." has been uploaded";
5.
} else{
6.
echo "There was an error uploading the file, please try again!";
7.
}
8.
?>

Parsed in 0.053 seconds, using GeSHi 1.0.8.4

Using above Php code :roll:, i can upload files from j2me. Can you any one tell me how to upload files from android. :?:
Reverse Phone Lookup

bruce bommarito
User offline. Last seen 43 weeks 5 hours ago. Offline
Joined: 04/13/2011
Android

I also am looking for the solution to this problem, I have tried everything and can't get it to work! - bruce bommarito

librasf
User offline. Last seen 1 year 1 week ago. Offline
Joined: 12/22/2010
Exception

Exception e)
{
a.setText("Error"
}

Can you anyone help me to solve this problem
mobilt bredband

librasf
User offline. Last seen 1 year 1 week ago. Offline
Joined: 12/22/2010
can anyone hlep me

can anyone hlep me too
Refinance Mortgage

pandorauk
User offline. Last seen 1 year 8 weeks ago. Offline
Joined: 12/07/2010
it is sometimes world of hard

it is sometimes world of hard to Pandora in a world of adults Pandora Bracelets

jhoffman
User offline. Last seen 2 years 33 weeks ago. Offline
Joined: 06/16/2009
Bump

First of all, I'd like to apologize for bumping such an old thread!

I've been struggling for about a week or so with this subject and still haven't come up with much. Basically what I need to do is the same as the OP - upload a file (of arbitrary type) to a web server from an Android phone.

I don't have any experience with web development or servers, but so far what I have learned is:
The basics of how forms, get, post, etc work.
The basics of how to read/write JSP.

I'm really struggling with implementing the code that Hobbs linked as I am very new to this type of development.I have looked into a number of tutorials but many are incomplete and others seem focused on serving up HTML for a human user to upload a file.

I would very much appreciate any direction as to teaching myself what I need to start implementing the server-side aspects of this code, and linking them up with client side code. (I am currently using Eclipse to write my code, and I have downloaded and toyed a bit with Tomcat)

hobbs
User offline. Last seen 12 weeks 1 day ago. Offline
Joined: 11/12/2007
PostAFile

No problem on the post of the first page, I thought that was locked out so no one could post anyways...

Check out the class "PostAFile" on this page, that looks like that might be the way you're supposed to submit a file...let me know if it works.

shadowdragon
User offline. Last seen 2 years 9 weeks ago. Offline
Joined: 11/20/2009
Thanks

Thanks hobbs fro your reply, Still i am gettings Error.

Regards,
Venkat

shadowdragon
User offline. Last seen 2 years 9 weeks ago. Offline
Joined: 11/20/2009
its working

now it's working!!!!. Thank you hobbs..

fidelio
User offline. Last seen 2 years 3 weeks ago. Offline
Joined: 01/13/2010
Uploading a file from Android to web server

Pls i'm having a similar problem, maybe i know how you used the said PostAFile class?

hobbs
User offline. Last seen 12 weeks 1 day ago. Offline
Joined: 11/12/2007
tutorial

Nice!! Was thinking about writing a tutorial