curl - PHP: check if image file exists using fopen -


this question using fopen check if file exists, not curl or getimagesize alternative methods not asking about.

i having been using following function in code couple years without problems , returning false, on valid images. don't know if accidentally created typo or if host changed version of php or may have caused appreciate if can spot might going wrong.

here code:

function image_exist($url) {             if (@fclose(@fopen( $url,  "r "))) {              // true; return true;             } else {              // false; return false;             }     } 

this returning false on valid images.

why use fopen() , fclose() when there's a function purpose?

function image_exist($url) {     return file_exists($url); } 

edit: you're correct not work remote files on http(s).


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

android - Go back to previous fragment -