यह केवल data(String, String, InputStream)
विधि के माध्यम से Jsoup 1.8.2 (13 अप्रैल, 2015) के बाद से समर्थित है।
String url = "http://www......com/....php";
File file = new File("/path/to/file.ext");
Document document = Jsoup.connect(url)
.data("user", "user")
.data("password", "12345")
.data("email", "[email protected]")
.data("file", file.getName(), new FileInputStream(file))
.post();
// ...
पुराने संस्करणों में, multipart/form-data
अनुरोध भेजना समर्थित नहीं है। आपकी सर्वश्रेष्ठ शर्त इस के लिए एक पूर्ण HTTP HTTP क्लाइंट का उपयोग कर रही है, जैसे कि Apache HttpComponents Client। आप अंततः HTTP क्लाइंट प्रतिक्रिया String
के रूप में प्राप्त कर सकते हैं ताकि आप इसे Jsoup#parse()
विधि पर फ़ीड कर सकें।
String url = "http://www......com/....php";
File file = new File("/path/to/file.ext");
MultipartEntity entity = new MultipartEntity();
entity.addPart("user", new StringBody("user"));
entity.addPart("password", new StringBody("12345"));
entity.addPart("email", new StringBody("[email protected]"));
entity.addPart("file", new InputStreamBody(new FileInputStream(file), file.getName()));
HttpPost post = new HttpPost(url);
post.setEntity(entity);
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(post);
String html = EntityUtils.toString(response.getEntity());
Document document = Jsoup.parse(html, url);
// ...