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 ?

1
  • 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. Commented Nov 24, 2012 at 17:49

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

3 Comments

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 .
I even tried to convert the data to base64 and then decode on the PHP part , but it doesn't work
stackoverflow.com/questions/8181182/… check it out..it may help you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.