title: how to convert the file content to byte array with php
body: <p>I want to save (insert) a uploaded file to a database with PHP, which the type of the database filed is varbinary.<br/>
  Finally I want to have the content of VarBinary (output) like when file is read in C# and then is stored in byte array and array is inserted to VarBinary.<br/>
  Also my connection to the database is with sqlsrv.<br/>
  The type of my files are just PDF and images.<br/>
  I try this code but my output is different with the output of C#:<br/></p>
  
  <pre><code>$handle=@fopen($_FILES["my_file"]["tmp_name"], 'rb');
  $content= file_get_contents($_FILES["my_file"]["tmp_name"]);
  $content = unpack("N*",$content);
  $content=  implode($content);
  $sql = "INSERT INTO files (file_data) VALUES (CONVERT(varbinary(MAX)?)";
  $params=array();
  array_push($params,$content);
  $table=sqlsrv_query( $conn, $sql, $params);
  </code></pre>
  
  <p>"$conn" is the name of my connection that works correctly.</p>