title: PHP converting an image to a binary file test
body: <p>I wanted to try to convert an image to Binary. </p>
  
  <p>I found a script online but it does not work.</p>
  
  <p>Could someone please advise why?</p>
  
  <pre><code>&lt;?php
  
  $image="image003.jpg";
  
  $data = fopen ($image, 'rb');
  $size=filesize ($image);
  $contents= fread ($fd, $size);
  fclose ($fd);
  
  $encoded= base64_encode($contents);
  
  echo $encoded;
  
   ?&gt;
  </code></pre>
  
  <p>I have an error come up on line 8 and 9</p>
  
  <pre><code>Warning: fread() expects parameter 1 to be resource
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Warning: fclose() expects parameter 1 to be resource,
  </code></pre>