public static void main(final String[] args) throws Exception {
        if (args.length != 1) {
            System.out.println("File path not given");
            System.exit(1);
        }
        try (final CloseableHttpClient httpclient = HttpClients.createDefault()) {
            final HttpPost httppost = new HttpPost("http://httpbin.org/post");

            final FileBody bin = new FileBody(new File(args[0]));
            final StringBody comment = new StringBody("A binary file of some kind", ContentType.TEXT_PLAIN);

            final HttpEntity reqEntity = MultipartEntityBuilder.create()
                    .addPart("bin", bin)
                    .addPart("comment", comment)
                    .build();


            httppost.setEntity(reqEntity);

            System.out.println("executing request " + httppost);
            httpclient.execute(httppost, response -> {
                System.out.println("----------------------------------------");
                System.out.println(httppost + "->" + new StatusLine(response));
                final HttpEntity resEntity = response.getEntity();
                if (resEntity != null) {
                    resEntity.writeTo(System.out);
                }
                System.out.flush();
                return null;
            });
        }
    }
Example how to use multipart/form encoded POST request.
httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientMultipartFormPost.java