title: FPDF Getting "Incorrect output destination" but the error code showing the correct destination
body: <p>I'm trying to use FPDF and FPDI to edit a PDF and add text to it. I keep getting an "Incorrect output destination" error but the destination is the correct location that I want it to create a file in, why does FPDF not like my output destination? </p>
  
  <p>This is in a laravel project</p>
  
  <pre><code>    $pdf = new \setasign\Fpdi\Fpdi();
      $pdf-&gt;AddPage();
      $pdf-&gt;setSourceFile(public_path('/pdf/higher.pdf'));
      $tplIdx = $pdf-&gt;importPage(1);
      $pdf-&gt;useTemplate($tplIdx, 10, 10, 100);
      $pdf-&gt;SetFont('Helvetica');
      $pdf-&gt;SetTextColor(255, 0, 0);
      $pdf-&gt;SetXY(30, 30);
      $pdf-&gt;Write(0, 'This is just a simple text');
      $pdf-&gt;Output(public_path('/pdf/'),'higher2');
      return $pdf;
  </code></pre>
  
  <p>and the error is: </p>
  
  <pre><code> message: "FPDF error: Incorrect output destination: /home/vagrant/code/project-name/public/pdf/"
  </code></pre>
  
  <p>I've also tried removing the "public_path()" and just setting it to <code>Output('pdf', 'higher2')</code> and no good there either. </p>
  
  <p>Furthermore I've also tried changing the name of the output pdf to <code>higher2.pdf</code> just in case it wanted to see the extension (but obviously it's having more of a problem with the destination and not the name) </p>
  
  <p>I've even tried changing permissions on this folder to be writable by anyone:</p>
  
  <pre><code>drwxrwxrwx  5 ion  staff    160 May 21 05:44 pdf
  </code></pre>
  
  <p>edit: Just to note I see that the method with the public_path() is trying to save to my vagrant folder for some reason, that's part of the reason I'm confused. When I try to save to '/pdf' without public_path(), I get this error:</p>
  
  <pre><code> message: "FPDF error: Incorrect output destination: /pdf/"
  </code></pre>
  
  <p><strong>edit 2:</strong></p>
  
  <p>I've also tried this: </p>
  
  <pre><code>$pdf-&gt;Output('F','/pdf/higher2.pdf');
  </code></pre>
  
  <p>and got the error: </p>
  
  <pre><code>message: "file_put_contents(/pdf/higher2.pdf): failed to open stream: No such file or directory"
  </code></pre>
  
  <p>and also tried the original name of the pdf which definitely exists and got the same error:</p>
  
  <pre><code>$pdf-&gt;Output('F','/pdf/higher.pdf');
  </code></pre>