note 79954 deleted from function.file-exists by danbrown

From: Date: Sun, 11 Jan 2009 18:38:55 +0000
Subject: note 79954 deleted from function.file-exists by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-149067@lists.php.net to get a copy of this message
Note Submitter: sea at circlesolo dot com ---- Very simple solution for a remote version of file_exists when checking to see if image URL exists This uses the getimagesize() function that attempts to read the width, height and other attributes for an image. My thought process was that if it returns a width, the image must exist... if not, replace it with a default or do whatever you want with it // can't find image, use a default thumbnail instead if(!$size=@getimagesize(protecturl($URL_OF_IMAGE))){ $replacementimageurl="images/defaultthumb.gif"; // same as return FALSE; } This sort of thinking can be applied to other file types using pre-existing functions.

« previous php.notes (#149067) next »