note 82245 added to function.getimagesize

From: Date: Wed, 02 Apr 2008 13:17:19 +0000
Subject: note 82245 added to function.getimagesize
Groups: php.notes 
Request: Send a blank email to php-notes+get-137859@lists.php.net to get a copy of this message
Could be useful (didn´t know where to post it): function getImageErrors( $filename, $type = "", $minWidth = 0, $minHeight = 0, $maxWidth = 0, $maxHeight = 0, $maxFileSize = 0 ) { $errors = array(); if ( file_exists( $filename ) ) { $ending = substr( $filename, strpos( $filename, "." ) ); if ( is_array( $type ) ) { $isTypeOf = false; foreach( $type as $eachtype ) { if ( $ending == $eachtype ) { $isTypeOf = true; } } if ( ! $isTypeOf ) { $errors[ 'type' ] = $ending; } } elseif ( $type != "" ) { if ( $ending != $type ) { $errors[ 'type' ] = $ending; } } $size = getimagesize( $filename ); if ( $size[ 0 ] < $minWidth ) { $errors[ 'minWidth' ] = $size[ 0 ]; } if ( $size[ 1 ] < $minHeight ) { $errors[ 'minHeight' ] = $size[ 1 ]; } if ( ( $maxWidth > $minWidth ) && ( $size[ 0 ] > $maxWidth ) ) { $errors[ 'maxWidth' ] = $size[ 0 ]; } if ( ( $maxHeight > $minHeight ) && ( $size[ 1 ] > $maxHeight ) ) { $errors[ 'maxHeight' ] = $size[ 1 ]; } if ( ( $maxFileSize > 0 ) && ( filesize( $filename ) > $maxFileSize ) ) { $errors[ 'maxFileSize' ] = filesize( $filename ); } } else { $errors[ 'filename' ] = "not existing"; } return ( count( $errors ) > 0 ? $errors : null ); } ---- Server IP: 212.124.37.9 Probable Submitter: 91.7.246.63 ---- Manual Page -- http://www.php.net/manual/en/function.getimagesize.php Edit -- https://master.php.net/note/edit/82245 Del: integrated -- https://master.php.net/note/delete/82245/integrated Del: useless -- https://master.php.net/note/delete/82245/useless Del: bad code -- https://master.php.net/note/delete/82245/bad+code Del: spam -- https://master.php.net/note/delete/82245/spam Del: non-english -- https://master.php.net/note/delete/82245/non-english Del: in docs -- https://master.php.net/note/delete/82245/in+docs Del: other reasons-- https://master.php.net/note/delete/82245 Reject -- https://master.php.net/note/reject/82245 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#137859) next »