1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
   |  
 
public String envoiImages(File image, String ccode, String url, String username, String password) throws HttpException, IOException{
 
PostMethod file = new PostMethod(url);
file.getParams().setBooleanParameter("http.protocol.expect-continue", true);
Part parts[] = {
            new FilePart("image", image), new StringPart("ccode", ccode), new StringPart("username", username), new StringPart("password", password)
        };
        file.setRequestEntity(new MultipartRequestEntity(parts, file.getParams()));        
        client.getHttpConnectionManager().getParams().setConnectionTimeout(1800000);
        int status = client.executeMethod(file);
        file.releaseConnection();
        if(status != 200)
            return HttpStatus.getStatusText(status);
        else
            return null;
 
	} | 
Partager