note 79954 added to function.file-exists
| From: | sea at circlesolo dot com | Date: | Fri, 21 Dec 2007 00:46:29 +0000 |
| Subject: | note 79954 added to function.file-exists | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-133827@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 66.207.199.35
Probable Submitter: 210.84.50.46
----
Manual Page -- http://www.php.net/manual/en/function.file-exists.php
Edit -- https://master.php.net/note/edit/79954
Del: integrated -- https://master.php.net/note/delete/79954/integrated
Del: useless -- https://master.php.net/note/delete/79954/useless
Del: bad code -- https://master.php.net/note/delete/79954/bad+code
Del: spam -- https://master.php.net/note/delete/79954/spam
Del: non-english -- https://master.php.net/note/delete/79954/non-english
Del: in docs -- https://master.php.net/note/delete/79954/in+docs
Del: other reasons-- https://master.php.net/note/delete/79954
Reject -- https://master.php.net/note/reject/79954
Search -- https://master.php.net/manage/user-notes.php