Skip to content
Advertisement

Uploading an image to server from android using HTTP POST request

I want to upload an image from my android app to a server. I don’t know where the problem is exactly in the code i’m using -it’s suppose to work ! -. It’s the first time I ever do this so I have little knowledge about it.

The code doesn’t catch any exceptions, yet it never enters the if statement where the server response is “200”.. and the image is never uploaded.

and could you please answer the following ?

1) what does this property mean ?

JavaScript

2) why is the meaning of this line ? I understand it’ll use the data output stream to write onto the server , but what are the parameters inside ?

JavaScript

===========

JavaScript

============================

PHP SCRIPT :

JavaScript

Advertisement

Answer

1)

JavaScript

there are two parameter,

first parameter : its a variable name(must be same as defined in php file) defined in your php file for getting file..

second parameter : its a file you want to upload..

2)

JavaScript

its like query string you are passing to DataOutputStream.. here you are passing file throug variable (which you defined upside) and file name for that file..

here, uploaded_file is a variable name defined in server(php) and

name & filename are field name (don’t change it)..you can change its value as your need

if you want nice tutorial for uploading file visit this link : Multipart HTTP Requests

Thank you…

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement