note 92451 added to function.getimagesize

From: Date: Fri, 24 Jul 2009 16:00:57 +0000
Subject: note 92451 added to function.getimagesize
Groups: php.notes 
Request: Send a blank email to php-notes+get-158701@lists.php.net to get a copy of this message
I had for quite some time been using getimagesize() to check for the existence of a remote image. This turned out to take way too long. The following curl solution only checks the http headers so it is much more efficient. <?php function checkRemoteFile($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); // don't download content curl_setopt($ch, CURLOPT_NOBODY, 1); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); if(curl_exec($ch)!==FALSE) { return true; } else { return false; } } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 74.165.35.188 ---- Manual Page -- http://www.php.net/manual/en/function.getimagesize.php Edit -- https://master.php.net/note/edit/92451 Del: integrated -- https://master.php.net/note/delete/92451/integrated Del: useless -- https://master.php.net/note/delete/92451/useless Del: bad code -- https://master.php.net/note/delete/92451/bad+code Del: spam -- https://master.php.net/note/delete/92451/spam Del: non-english -- https://master.php.net/note/delete/92451/non-english Del: in docs -- https://master.php.net/note/delete/92451/in+docs Del: other reasons-- https://master.php.net/note/delete/92451 Reject -- https://master.php.net/note/reject/92451 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#158701) next »