Toggle navigation
Dashboard
Dashboard Tracker
Add / Edit My Forums
System Announcements
Discussion
Active Thread Feed
Top Threads Today
Top Threads This Week
Top Threads Library
Go!
View All
View All
Login
Logout
Home
Forums Index
Server Side
/
PHP Server Side Scripting
10:53 pm Apr 27, 2026
This page requires javascript.
Forum Moderators:
coopster
Message Too Old, No Replies
Binary Stream
How to save back to a file.
gosman
Msg#:4539918
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?
gosman
Msg#:4540166
11:42 am on Jan 29, 2013
(gmt 0)
Any one?
swa66
Msg#:4540177
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.
gosman
Msg#:4540672
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
<stream>UEsDBBQAAAAIANaTPkKNE32Qcx4AAKHcAAAQACQAUHJvZEZlZWRGaWxlLnhtbAoAIAAAAAAAAQAYAJ7BnOoX/80BnsGc6hf/zQGewZzqF.......</stream>
I parse the XML storing the stream in $response
$file=fopen("/filepath/test.zip","wb");
fwrite($file,$response);
fclose($file);
The zip file gets created as expected, however when I try opening it, it gives an error. "Not a valid ZIP file"
swa66
Msg#:4540713
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
...]
gosman
Msg#:4540865
9:57 am on Jan 31, 2013
(gmt 0)
Thank you swa66
base64_decode($response);
Was the solution.
Join The Conversation
Register
For Free! -
Become a
Pro Member
!
See forum categories
-
Enter the Forum
Moderators and Top Contributors
Moderator List
| Top Contributors:
This Week
,
This Month
,
Mar
,
Feb
,
Archive
,
Top 100 All Time
,
Top Voted Members
Hot Threads This Week
April 2026 Google Search Observations
Hello again, it's been a while
AdSense Earnings and Observations - April 2026
Do you get tired of others copying your content?
5 SEO Tips That Actually Worked for My Blog in 2026
I need some SEO help
iPhone Safari 26.4.1 errors: IPv4 & Host
2025 Link Building Trends and Insights
Does SEO matter any more?
SEO question
Home
Forums Index
Server Side
/
PHP Server Side Scripting
10:53 pm Apr 27, 2026