Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!
RuneMate will permanently shut down on August 7, 2026
due to events outside our control. You can continue using RuneMate until this date after which it will no longer be available. Thank you to everyone that contributed to RuneMate's success and to the community for the opportunity to serve you all these years.

  • Learn about RuneMate Vault and how its zero knowledge local encryption already protects your sensitive information.
  • Edit or delete your RuneMate account from your Account Settings.
  • All account upgrade subscriptions have been cancelled. No action required.

A project

I've been called a god before.
Joined
Aug 5, 2014
Messages
3,211
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
 
First Bot Author
Joined
Aug 7, 2013
Messages
262
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.
 
Joined
Nov 3, 2013
Messages
609
Just use the ImageIO class. It will do an http request under the hood.

Ex:
Code:
URL url = new URL("http://www.website.com/image/mypic.jpg");
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
 
I've been called a god before.
Joined
Aug 5, 2014
Messages
3,211
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.
How exactly? I am trying to find something on google. but everyhting is outdated.
Just use the ImageIO class. It will do an http request under the hood.

Ex:
Code:
URL url = new URL("http://www.website.com/image/mypic.jpg");
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
 
Top