samedi 27 décembre 2014

Free HTTP sites to Upload a file using Java program


Vote count:

0




I am trying to upload a file to a HTTP website using a Java program . Can anyone please help with the available sites to do so ? this is my code:-



public class PostFile {
public static void main(String[] args) throws Exception {
HttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);

HttpPost httppost = new HttpPost("xxxx"); // Any website that accepts http uploads
File file = new File("c:/TRASH/zaba_1.jpg");

MultipartEntity mpEntity = new MultipartEntity();
ContentBody cbFile = new FileBody(file, "image/jpeg");
mpEntity.addPart("userfile", cbFile);


httppost.setEntity(mpEntity);
System.out.println("executing request " + httppost.getRequestLine());
HttpResponse response = httpclient.execute(httppost);
HttpEntity resEntity = response.getEntity();

System.out.println(response.getStatusLine());
if (resEntity != null) {
System.out.println(EntityUtils.toString(resEntity));
}
if (resEntity != null) {
resEntity.consumeContent();
}

httpclient.getConnectionManager().shutdown();
}
}


I need list of http websites where we can upload files using a Java program . TIA



asked 50 secs ago

Newbie

481






Free HTTP sites to Upload a file using Java program

Aucun commentaire:

Enregistrer un commentaire