0

I want to send files data from Java to PHP and then the php saves the data to a file . here's my code : the java code :

 byte[] data=...
 str = new String(data,"ISO-8859-1"); //convert data to String .
// send(str);

and here's the php script:

$data = // get the data from java .  
fwrite($fr1,$data); 

the problem is that this script work only with text files and not for image files and Zip files . how can I solve that ?

Walllzzz
  • 550
  • 1
  • 5
  • 16
  • Have you looked into PHP's Imagick or GD extensions? PHP also has a zip extension; you can find all of these in the docs. – Ian Hunter Nov 24 '12 at 17:49

1 Answers1

1

Can you please make it clear?..do you want to read the image or zip file...or want to send them.

in my opinion, Send the path of the image and zip file which you to be read in PHP that would be better approach. There won't be any chance of degrading the quality of the image or problem in extracting the zip file etc.

Below links may help you:

http://blog.joa-ebert.com/2006/05/01/save-bytearray-to-file-with-php/
Saving a bytearray with php received from Flex Air app

Community
  • 1
  • 1
Sourabh
  • 59
  • 1
  • 15
  • I made the part that sends and receive the image , the problem is that when I convert the file bytes in Java to String using String(byte[]) and saving the same data after sending it to php in a file using fwrite($data) , the file generated is not a valide file . – Walllzzz Nov 24 '12 at 17:59
  • I even tried to convert the data to base64 and then decode on the PHP part , but it doesn't work – Walllzzz Nov 24 '12 at 18:16
  • http://stackoverflow.com/questions/8181182/read-and-write-pgm-p5-image-file-in-php check it out..it may help you – Sourabh Nov 24 '12 at 20:25