How can i write a simple Android file uploaded using a POST method to a PHP server
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Please download HttpComponents and add it to your Android Project. If you want to upload a file with a POST method you have to use Multipart.
Source: Post multipart request with Android SDK
Also read this tutorial for an AsyncTask example. An AsyncTask is a little bit harder to code, but if you don’t use it your app is going to upload files in the main thread. Your application will freeze while uploading a file, if it takes longer then 5 seconds Android will say that your Application is not responding. If you use an AsyncTask for downloading/uploading a file Android creates a new Thread and your application won’t freeze.
Please note that if you use multiple AsyncTasks Android will execute the AsyncTasks one at the time, you cannot run multiple AsyncTasks at the same time but in the most cases you don’t have to.