if($_FILES['server_banner']['error'] != 4) {
 
    
 
    /*
 
 
        Upload(
 
 
            - variable name (<input type="file" name="THIS VALUE" />
 
            - upload target
 
            - image dimensions (optional)
 
            - IMAGE_EQUAL, IMAGE_MAX (optional)
 
                IMAGE_EQUAL:
 
                - image must have defined dimensions
 
                IMAGE_MAX:
 
                - you defines max acceptable image dimensions
 
        )
 
 
    */
 
 
 
    $banner = new Upload('server_banner', ROOT.'Upload/banners/', array('468', '60'), IMAGE_EQUAL);
 
 
    // DEFINE ACCEPTABLE FILESIZE
 
 
    $banner->MaxSize(204800); // 200 kb
 
 
    // DEFINE ACCEPTABLE FILE FORMAT
 
    // If you'll not trigger this method, upload'll accept files of any types
 
 
    $banner->AllowFormat('image/jpeg', 'image/gif', 'image/png');
 
                        
 
    if(!$banner->Upload()) {
 
                                                
 
        switch($banner->GetError()) {
 
                                
 
            case ERROR_BAD_DIMENSIONS:
 
                echo 'Bad image dimensions. Acceptable: 468x60px';
 
            break;
 
                                    
 
            case ERROR_FILE_TOO_BIG:
 
                echo 'File size exceeds 200kb. Size of an uploaded file is: '.$banner->GetFileSize();
 
            break;
 
                                    
 
            case ERROR_BAD_FORMAT:
 
                echo 'Bad file format. Acceptable: jpg, gif, png';
 
            break;
 
                                
 
        }
 
                        
 
    }
 
 
    else echo 'File has been uploaded to '.$banner->GetUploadedName();
 
                                                
 
}
 
 |