File exists, but it doesn't, except it does

I’m using dompdf to generate pdf’s to send as an attachment with e-mails, the problem is I can’t send the e-mail before the pdf was generated (for obvious reasons, you can’t attach something that doesn’t exists).

Now my problem is, I don’t want to send the e-mail until the file exists, I couldn’t find a callback method for dompdf (maybe I’m blind) so I tried doing something with file_exists.

However, when I have 2 lines of code, the top one having
echo file_exists($file);
and the bottom one having
$f = fopen($file, ‘rb’);

I get returned a 1 from the first, indicating the file exists. But after that I get a reading error that says the file doesn’t exists…

Is there any way to check if a function will return an error without it actually returning the error?

I had the exact same problem with PHP a week back or so. Rebooting the PC solved it. Still don’t know what happened there :shifty: (Wamp2 @ Win7)

Maybe because you open file but not close, i’m not sure. :slight_smile:

What are you using to check to see if the file exists once you use fopen?

Are you checking the headers like this:

if (strpos($http_response_header[0], ‘200’) !== false)

or something different?