Changeset 356

Show
Ignore:
Timestamp:
03/20/06 14:17:48 (2 years ago)
Author:
argh
Message:

Fixed a notice in the File element when the maxsize attribute is not set.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/autopackage.php

    r352 r356  
    4545  - File: determining the session's save path now correctly uses the php.ini setting if available (argh) 
    4646  - File: improved error messages with useful information and error solving hints (argh) 
     47  - File: fixed the notice that occurrs when the maxsize attribute is not set (argh) 
    4748 
    4849* Rules 
  • trunk/package.php

    r352 r356  
    5555  - File: determining the session's save path now correctly uses the php.ini setting if available (argh) 
    5656  - File: improved error messages with useful information and error solving hints (argh) 
     57  - File: fixed the notice that occurrs when the maxsize attribute is not set (argh) 
    5758 
    5859* Rules 
  • trunk/patForms/Element/File.php

    r355 r356  
    308308   /** 
    309309    * initialze file elemente 
    310     *  
     310    * 
    311311    * - check temporary file upload dir required when sessions are used 
    312312    * - check file upload in php.ini 
    313     *  
     313    * 
    314314    * @access   private 
    315315    * @return   mixed   $success    True on success, a patError object otherwise 
     
    322322                                                'php.ini doesn\'t allow file upload see: "file_uploads"' ); 
    323323        } 
    324          
     324 
    325325        // require temporary directory if session-support is switched on 
    326326        if( $this->useSession() ) 
     
    328328            // store the required flag for easy access 
    329329            $tempdir    =   $this->attributes['tempdir']; 
    330              
     330 
    331331            // use php.ini default 
    332332            if( empty( $tempdir ) ) { 
     
    336336                } 
    337337            } 
    338              
     338 
    339339            if( !is_dir( $tempdir ) && !is_writeable( $tempdir ) ) { 
    340                 $error = patErrorManager::raiseError(  
     340                $error = patErrorManager::raiseError( 
    341341                    PATFORMS_FILE_ERROR_TEMPDIR_NOT_VALID, 
    342342                    'Session support is on but cannot work', 
     
    346346                    'is set to "'.$this->getAttribute( 'tempdir' ).'".' 
    347347                ); 
    348                  
     348 
    349349                return $error; 
    350350            } 
    351              
     351 
    352352            $this->tempdir  =   $tempdir; 
    353353        } 
     
    359359                                            'Destination folder "' . $this->attributes['uploaddir'] . '" does not exist or is not writeable!' ); 
    360360        } 
    361      
     361 
    362362        return true; 
    363363    } 
     
    393393        } 
    394394 
    395         $this->attributes["name"]   =   $name;       
     395        $this->attributes["name"]   =   $name; 
    396396        $valueElement =   $this->createHiddenTag( $this->attributes["value"] ); 
    397397        /* 
     
    443443        $empty      =   false; 
    444444        $mime       =   false; 
    445         $uploade    =   false;       
     445        $uploade    =   false; 
    446446 
    447447        $error      =   UPLOAD_ERR_NO_FILE; 
     
    451451        if( isset( $_FILES ) ) { 
    452452            $files = $_FILES; 
    453              
     453 
    454454            if( ( $namespace = $this->getNamespace() ) && isset( $files[$namespace] ) ) { 
    455455                $files = $files[$namespace]; 
    456456            } 
    457457        } 
    458          
     458 
    459459        // file was just uploaded 
    460460        if( !empty( $files ) && ( isset($files[$nameUpload] ) || isset( $files['name'][$nameUpload] ) ) ) { 
     
    499499                if( $oldfile = $this->getSessionValue( 'uploadfile' ) ) { 
    500500                    unlink( $oldfile ); 
    501                 }                 
     501                } 
    502502            } 
    503503 
     
    510510                return false; 
    511511            } 
    512              
    513             if( $size > $this->attributes['maxsize'] ) { 
     512 
     513            $maxsize = $this->getAttribute( 'maxsize' ); 
     514            if( $maxsize && $size > $this->attributes['maxsize'] ) { 
    514515                $this->addValidationError( 3, array( 'maxsize' => $this->attributes['maxsize'] ) ); 
    515516                return false; 
     
    585586        if( $this->useSession() && !$restored ) { 
    586587            $tempfile   =   tempnam( $this->tempdir, $name . '_' ); 
    587              
     588 
    588589            if( !move_uploaded_file( $uploadFile, $tempfile ) ) { 
    589590                return patErrorManager::raiseError( PATFORMS_FILE_ERROR_CANNOT_MOVE_UPLOAD_FILE, 
     
    636637                $files = $files[$namespace]; 
    637638            } 
    638          
     639 
    639640            if( isset( $files[$nameUpload]["tmp_name"] ) ) { 
    640641                $uploadFile =   $files[$nameUpload]["tmp_name"]; 
    641             }       
     642            } 
    642643            else if( isset( $files["tmp_name"][$nameUpload] ) ) { 
    643644                $uploadFile =   $files["tmp_name"][$nameUpload]; 
     
    649650            return true; 
    650651        } 
    651          
     652 
    652653        // cannot use 'move_upload_file()' in case of usage of sessions 
    653654        if( !rename( $uploadFile, "$dir/$value" ) ) { 
    654             $error = patErrorManager::raiseError(  
     655            $error = patErrorManager::raiseError( 
    655656                PATFORMS_FILE_ERROR_CANNOT_MOVE_UPLOAD_FILE, 
    656657                "Cannot upload file", 
    657                 "Could not move file '".$uploadFile."' to '".$dir."/".$value."'"  
     658                "Could not move file '".$uploadFile."' to '".$dir."/".$value."'" 
    658659            ); 
    659              
     660 
    660661            return $error; 
    661662        } 
    662          
     663 
    663664        chmod( "$dir/$value", $this->_getPermission() ); 
    664665        return true; 
     
    723724            return true; 
    724725        } 
    725      
     726 
    726727        if( empty( $this->attributes["mimetype"] ) ) { 
    727728            return true;