I am extracting a file using
$fp = fopen('uploads/Team/img/'.$team_id.'.png', "rb"); $str = stream_get_contents($fp); fclose($fp);
and then the method returns it as an image. But when fopen () fails because the file does not exist, it throws an error:
[{"message":"Warning: fopen(uploads\/Team\/img\/1.png): failed to open stream: No such file or directory in C:\...
This will return as json, obviously.
The question now is: how can I catch an error and prevent the method from throwing this error directly to the client?
source share