Read in file as binary data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
sharyn
Forum Commoner
Posts: 33
Joined: Tue Jun 15, 2004 6:39 pm
Location: So Cal

Read in file as binary data

Post by sharyn »

I'm trying to use the Zend ZIP class and at some point I have to read my file into a binary data string and then store it into the Zip file. This may be a very simple process, but I don't know how to do it. The documentation at Zend just says

Code: Select all

//add the binary data stored in the string 'filedata'
  $filedata = "(read your file into $filedata)";
  $zipfile -> add_file($filedata, "dir/file.txt");
The files are of varying types : text, jpg, tif, xls, etc...

I've looked around various sites including this one, but I may be typing in the wrong search words. In anycase, can anyone give me a clue?

Thanks a mill,
- sharyn
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

file_get_contents() is binary safe

(so if fopen() btw)
User avatar
sharyn
Forum Commoner
Posts: 33
Joined: Tue Jun 15, 2004 6:39 pm
Location: So Cal

[*RESOLVED*]

Post by sharyn »

Rehfeld,

file_get_contents() was exactly what I needed. Thanks a mill :D

- sharyn
Post Reply