Code:
if (pointClicked.getY() > 400.0 && pointClicked.getX()>300.0) {
            
            BufferedImage img = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);

            GCanvas canvas = getGCanvas();

            canvas.paint(img.createGraphics());
            
             
            
           try{
                //encoder.encode(img);
                HttpURLConnection connection = (HttpURLConnection) new URL("http://www.mywebsite.com/writepicture.php").openConnection();
                connection.setDoOutput(true);
                connection.setDoInput(true);
                connection.setUseCaches(false);
                connection.setRequestMethod("POST");
                connection.setRequestProperty("Content-Type", "img/png");
                
                
                OutputStream wr = connection.getOutputStream();
                ImageIO.write(img, "png", wr);
                wr.flush();
                wr.close();
                
                connection.disconnect();
           }
            catch(Exception except){
                except.printStackTrace();
            }

}
The above code is the clients code and I am trying to fix it, he says the top portion above try, works just fine but he is having trouble getting the image drawn within the Java applet to be passed to his php and saving it to the server

I have the php end of things just fine and can code whats needed to accept an incoming image and save it to a file on the server, I just need to know if the above code is ok or what needs changing to pass the image to the php and how the image is being passed to php so I know what method to use to intercept it and save it.

I am new to Java so am clueless with this lol