homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Binary Stream
How to save back to a file.

 5:19 pm on Jan 28, 2013 (gmt 0)

One of my suppliers provides me with an XML file. This XML file contains a CDATA section with a binary stream of a zipped CSV file.

Once I've parsed the XML file and retrieved the Binary Stream, how do I save it back to a ZIP file?



 11:42 am on Jan 29, 2013 (gmt 0)

Any one?


 1:12 pm on Jan 29, 2013 (gmt 0)

You open a file for writing (binary if you're on wintendo), write to it and close it.

fopen: [php.net...]
fwrite: [php.net...]
fclose: [php.net...]

Try it, if you fail to get the result, show relevant code.


 6:53 pm on Jan 30, 2013 (gmt 0)

Hi Swa66

I tried that and it doesn't work. Here is what is says in the manual

"The response object of this method will return you a binary stream which you
will need to create a zip file out of"

And here is the XML response


I parse the XML storing the stream in $response


The zip file gets created as expected, however when I try opening it, it gives an error. "Not a valid ZIP file"


 8:39 pm on Jan 30, 2013 (gmt 0)

Your stream looks not to be binary. I'd guess it to be base64 encoded.

php has what you need to decode base64 (assuming it is base64) [php.net...]


 9:57 am on Jan 31, 2013 (gmt 0)

Thank you swa66


Was the solution.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved