title: Convert uploaded document to binary/ascii and send as a api variable
body: <p>I need to write a code which uploads doc file and send its content in binary or ASCII as a API variable .I can think of two approach (1)Upload the file and then read its content and send the data to api (2)Upload the file and then store its content and access the blob data and send to api.</p>
  
  <p>I would like to ask which one is better. Right now i am using second option.</p>
  
  <p>Now my problem is I am able to do upload part and storing to database part as a blob data ,
  but when i access the blob data using mysql query and send result to API . The API says that its not in binary or ASCII . And when i echo the result of query it shows jibberish data so i assume that its not in binary or ascii . Please tell me how to pass this blob data to API as Binary/ASCII.</p>
  
  <pre><code>&lt;?php
  
  $filename = "resume3.doc";
  $handle = fopen($filename, "rb");
  $contents = fread($handle, filesize($filename));
  fclose($handle);
  
  // URL of Form
  $url = "http://rezscore.com/a/2901e8/grade";
  //create the final string to be posted
  $post_string = "resume=$contents";
  
  //create cURL connection
  $curl_connection = curl_init($url);
  
  //set options
  curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
  curl_setopt($curl_connection, CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0;   Windows NT 5.1)");
  curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
  
  //set data to be posted
  curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
  
  //perform our request
  $result = curl_exec($curl_connection);
  
  print $result;
  
  //close the connection
  curl_close($curl_connection);      
  ?&gt;
  </code></pre>
  
  <p>The file should be a resume and the api returns grade for the resume. <a href="http://rezscore.com/" rel="nofollow">http://rezscore.com/</a></p>
  
  <p>Thanks</p>