A project

Discussion in 'Projects' started by Qosmiof2, Apr 24, 2016.

  1. I have a server where i will put my images to. Now i am wondering what would be the best wa to transfer images from client (java) to my server (php). I read i can use two options:

    a) Sockets
    b) byte(code?)

    Which one would be better and why? If there is anything else that is even better, i would like You to tell me what is it. Thank you
  2. Sockets are intended to remain opened, so unless you have a chat, they're probably not a good idea.
    You can make simple POST requests with the image data and PHP will be able to handle it.
  3. Just use the ImageIO class. It will do an http request under the hood.

    Code (Text):
    1. URL url = new URL("http://www.website.com/image/mypic.jpg");
    2. Image image = ImageIO.read(url);
    Take a look at lines 143-180 here for an example on how to save the files out to a local image cache:
    Exia-Mining-All-In-One/AIOMinerGUI.java at master · JohnRThomas/Exia-Mining-All-In-One · GitHub

    Edit: Sorry read that wrong, you want to go java -> server. My bad.

    Check out this link:
    Send image file using java HTTP POST connections
  4. How exactly? I am trying to find something on google. but everyhting is outdated.

Share This Page