View Single Post
Old 12-20-2007, 01:34 AM   #3 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Andrew View Post
What are you trying to accomplish with the following?
PHP Code:
$handler == $handler.".JPG";
$handler == $handler.".PNG";
$handler == $handler.".GIF";
$handler == $handler.".BMP"
If you are trying to do what I think you are doing, this should suffice.
PHP Code:
function isImage($handler) {
    
/* Make the string all lowercase */
    
$handler strtolower($handler);
    
/* Get the extension */
    
$extension explode('.'$handler);
    
$extension array_splice($extension, -11);
    
/* Check if filetype is allowed */
    
if ($extension[0] == 'jpg' || $extension[0] == 'png' || $extension[0] == 'gif' || $extension[0] == 'bmp') {
        
/* Check if the file exists */
        
if (file_exists($handler)) {
            echo 
'File exists.';
        } else {
            echo 
'File does not exist.';
        }
    } else {
        echo 
'Unknown file type.';
    }

Thanks, I'll try it! :D
Orc is offline  
Reply With Quote