12-20-2007, 02:34 AM
|
#3 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
|
Quote:
Originally Posted by Andrew
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, -1, 1);
/* 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
|
|
|
|