title: How to insert binary data to SQL using Laravel 5.*
body: <p>I would like to save an image into a varbinary(max) field in MSSQL.</p>
  
  <p>The store method in my controller looks like this:</p>
  
  <pre><code>public function store(Request $request)
      {
  
          $vorname = $request-&gt;input('vorname');
  
          $nachname = $request-&gt;input('nachname');
  
          $file = $request-&gt;file('avatar');
  
          $extension = $file-&gt;clientExtension();
  
          $fullname = $nachname . "_" . $vorname . "." . $extension;
  
          $file-&gt;storeAs('avatars' , $fullname);
  
          $path = storage_path() . "\app\avatars\\". $fullname;
  
          $imageData = unpack("H*", file_get_contents($path));
  
          Mitarbeiter::create([
  
              'PersonalNr' =&gt; request('personalnr'),
              'Mitarbeiterschluessel' =&gt; request('mitarbeiterkey'),
              'Vorname' =&gt; $vorname,
              'Familienname' =&gt; $nachname,
              'Bild' =&gt; $imageData[1]
  
          ]);
  
          return view('welcome');
  
      }
  </code></pre>
  
  <p>I'm getting an error:</p>
  
  <blockquote>
    <p>SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL
    Server]Die implizite Konvertierung vom nvarchar(max)-Datentyp in
    varbinary(max) ist nicht zulässig.</p>
  </blockquote>
  
  <p>translated:</p>
  
  <blockquote>
    <p>Implicit conversion from the nvarchar (max) data type to varbinary
    (max) is not allowed.</p>
  </blockquote>