title: Using TesseractOCR in Laravel
body: <p>I'm trialing out using TesseractOCR on a new website.</p>
  
  <p>I've installed a new version of Laravel (5.2.4), installed Tesseract on my server (Debian Jessie) and installed a PHP wrapper for Tesseract; <a href="https://github.com/thiagoalessio/tesseract-ocr-for-php" rel="nofollow">tesseract-ocr-for-php</a>.</p>
  
  <p>I've followed all the setup instructions and installed the package on the application.</p>
  
  <p>In my <code>routes.php</code> file I had:</p>
  
  <pre><code>Route::get('/test', function () {
  $tesseract = new TesseractOCR(asset('images/myimage.jpg'));
  echo $tesseract-&gt;recognize();
  });
  </code></pre>
  
  <p>Where the image <code>myimage.jpg</code> exists inside a folder called <code>images</code> inside the <code>public</code> folder.</p>
  
  <p>When I navigate to <code>example.com/test</code> I get:</p>
  
  <blockquote>
    <p>ErrorException in TesseractOCR.php line 235:
    file_get_contents(/tmp/75176598.txt): failed to open stream: No such
    file or directory</p>
  </blockquote>
  
  <p>According to the <code>readme.md</code> you can solve that issue by using <code>$tesseract-&gt;setTempDir('./my-temp-dir');</code>.</p>
  
  <p>As such I tried changing my <code>routes.php</code> file to:</p>
  
  <pre><code>Route::get('/test', function () {
  $tesseract = new TesseractOCR(asset('images/myimage.jpg'));
  $tesseract-&gt;setTempDir('/var/www/tesseract/public/images');
  echo $tesseract-&gt;recognize();
  });
  </code></pre>
  
  <p>However that just gives the same error with a different file path:</p>
  
  <blockquote>
    <p>ErrorException in TesseractOCR.php line 235:
    file_get_contents(/var/www/tesseract/public/images/1770521095.txt):
    failed to open stream: No such file or directory</p>
  </blockquote>
  
  <p><strong>How do I solve this error?</strong></p>