Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String url = "http://yourserver.com/upload.php";
- File file = new File("myfileuri");
- try {
- HttpClient httpclient = new DefaultHttpClient();
- HttpPost httppost = new HttpPost(url);
- InputStreamEntity reqEntity = new InputStreamEntity(new FileInputStream(file), -1);
- reqEntity.setContentType("binary/octet-stream");
- reqEntity.setChunked(true); // Send in multiple parts if needed
- httppost.setEntity(reqEntity);
- HttpResponse response = httpclient.execute(httppost);
- //Do something with response...
- } catch (Exception e) {
- e.printStackTrace();
- }
- httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
- File myFile = new File("/path/to/file.png");
- RequestParams params = new RequestParams();
- try {
- params.put("profile_picture", myFile);
- } catch(FileNotFoundException e) {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement