Reading file in as binary in php

sharyn's picture

They have: 18 posts

Joined: Aug 2004

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

//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

sharyn's picture

They have: 18 posts

Joined: Aug 2004

I ended up using file_get_contents() which worked perfectly.

- sharyn

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.