A project

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

  1. Qosmiof2

    Qosmiof2 Qosidog3 - I write bots not tragedies.

    Joined:
    Aug 5, 2014
    Messages:
    2,248
    Likes Received:
    666
    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. Salvation

    Salvation First Bot Author

    Joined:
    Aug 7, 2013
    Messages:
    249
    Likes Received:
    63
    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. Exia

    Joined:
    Nov 3, 2013
    Messages:
    605
    Likes Received:
    257
    Just use the ImageIO class. It will do an http request under the hood.

    Ex:
    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. Qosmiof2

    Qosmiof2 Qosidog3 - I write bots not tragedies.

    Joined:
    Aug 5, 2014
    Messages:
    2,248
    Likes Received:
    666
    How exactly? I am trying to find something on google. but everyhting is outdated.
     

Share This Page

Loading...