i m new to this android application development i would be very much grateful to you if you people will guide me for making an android application that allow me to upload photos to my current page from my device same as we upload profile pic in Facebook Thanx in advance
Asked
Active
Viewed 126 times
-2
-
2This is way too broad of a question for SO. You need to do some research, read through the Android Developers documentation, look through the sample code, and generally post here for specific problems you're experiencing after researching yields you no answers. – Kevin Coppock Jun 15 '12 at 18:49
2 Answers
1
client side code
try
{
HttpURLConnection httpUrlConnection = (HttpURLConnection)new URL("/upload.php").openConnection();
httpUrlConnection.setDoOutput(true);
httpUrlConnection.setRequestMethod("POST");
OutputStream os = httpUrlConnection.getOutputStream();
BufferedInputStream fis = new BufferedInputStream(new FileInputStream("/mnt/sdcard/"+fileName));
for (int i = 0; i < 100000; i++) {
os.write(fis.read());
}
os.close();
BufferedReader in = new BufferedReader(new InputStreamReader(httpUrlConnection.getInputStream()));
String s = null;
while ((s = in.readLine()) != null) {
System.out.println(s);
}
in.close();
fis.close();
}
catch(Exception ex)
{
ex.printStackTrace();
}
You could use this server side code in php
$filename = "name.jpg";
$fileData = file_get_contents('php://input');
$fhandle = fopen($filename, 'wb');
fwrite($fhandle, $fileData);
fclose($fhandle);
echo "success";

ifaim
- 350
- 1
- 3
- 9
0
As it has been posted by kcoppock in the comments, its a very broad question. I'd like to recommend you to ready something about these topics:
With these links you can begin some of your researches... ;-)