public function validateUploadedFile($sName, array $aUploadedFile)
    {
        $this->sErrorMessage = '';
        // Verify the file extension
        $xDefault = $this->xConfig->getOption('upload.default.types');
        $aAllowed = $this->xConfig->getOption('upload.files.' . $sName . '.types', $xDefault);
        if(is_array($aAllowed) && !in_array($aUploadedFile['type'], $aAllowed))
        {
            $this->sErrorMessage = $this->xTranslator->trans('errors.upload.type', $aUploadedFile);
            return false;
        }
        // Verify the file extension
        $xDefault = $this->xConfig->getOption('upload.default.extensions');
        $aAllowed = $this->xConfig->getOption('upload.files.' . $sName . '.extensions', $xDefault);
        if(is_array($aAllowed) && !in_array($aUploadedFile['extension'], $aAllowed))
        {
            $this->sErrorMessage = $this->xTranslator->trans('errors.upload.extension', $aUploadedFile);
            return false;
        }
        // Verify the max size
        $xDefault = $this->xConfig->getOption('upload.default.max-size', 0);
        $iSize = $this->xConfig->getOption('upload.files.' . $sName . '.max-size', $xDefault);
        if($iSize > 0 && $aUploadedFile['size'] > $iSize)
        {
            $this->sErrorMessage = $this->xTranslator->trans('errors.upload.max-size', $aUploadedFile);
            return false;
        }
        // Verify the min size
        $xDefault = $this->xConfig->getOption('upload.default.min-size', 0);
        $iSize = $this->xConfig->getOption('upload.files.' . $sName . '.min-size', $xDefault);
        if($iSize > 0 && $aUploadedFile['size'] < $iSize)
        {
            $this->sErrorMessage = $this->xTranslator->trans('errors.upload.min-size', $aUploadedFile);
            return false;
        }
        return true;
    }
public function validateUploadedFile($sName, array $aUploadedFile)
    {
        $this->sErrorMessage = '';
        // Verify the file extension
        $xDefault = $this->xConfig->getOption('upload.default.types');
        $aAllowed = $this->xConfig->getOption('upload.files.' . $sName . '.types', $xDefault);
        if(is_array($aAllowed) && !in_array($aUploadedFile['type'], $aAllowed))
        {
            $this->sErrorMessage = $this->xTranslator->trans('errors.upload.type', $aUploadedFile);
            return false;
        }
        // Verify the file extension
        $xDefault = $this->xConfig->getOption('upload.default.extensions');
        $aAllowed = $this->xConfig->getOption('upload.files.' . $sName . '.extensions', $xDefault);
        if(is_array($aAllowed) && !in_array($aUploadedFile['extension'], $aAllowed))
        {
            $this->sErrorMessage = $this->xTranslator->trans('errors.upload.extension', $aUploadedFile);
            return false;
        }
        // Verify the max size
        $xDefault = $this->xConfig->getOption('upload.default.max-size', 0);
        $iSize = $this->xConfig->getOption('upload.files.' . $sName . '.max-size', $xDefault);
        if($iSize > 0 && $aUploadedFile['size'] > $iSize)
        {
            $this->sErrorMessage = $this->xTranslator->trans('errors.upload.max-size', $aUploadedFile);
            return false;
        }
        // Verify the min size
        $xDefault = $this->xConfig->getOption('upload.default.min-size', 0);
        $iSize = $this->xConfig->getOption('upload.files.' . $sName . '.min-size', $xDefault);
        if($iSize > 0 && $aUploadedFile['size'] < $iSize)
        {
            $this->sErrorMessage = $this->xTranslator->trans('errors.upload.min-size', $aUploadedFile);
            return false;
        }
        return true;
    }
public function validateUploadedFile ( $ sName , array $ aUploadedFile ) { $ this -> sErrorMessage = '' ; // Verify the file extension $ xDefault = $ this -> xConfig -> getOption ( 'upload.default.types' ) ; $ aAllowed = $ this -> xConfig -> getOption ( 'upload.files.' . $ sName . '.types' , $ xDefault ) ; if ( is_array ( $ aAllowed ) && ! in_array ( $ aUploadedFile [ 'type' ] , $ aAllowed ) ) { $ this -> sErrorMessage = $ this -> xTranslator -> trans ( 'errors.upload.type' , $ aUploadedFile ) ; return false ; } // Verify the file extension $ xDefault = $ this -> xConfig -> getOption ( 'upload.default.extensions' ) ; $ aAllowed = $ this -> xConfig -> getOption ( 'upload.files.' . $ sName . '.extensions' , $ xDefault ) ; if ( is_array ( $ aAllowed ) && ! in_array ( $ aUploadedFile [ 'extension' ] , $ aAllowed ) ) { $ this -> sErrorMessage = $ this -> xTranslator -> trans ( 'errors.upload.extension' , $ aUploadedFile ) ; return false ; } // Verify the max size $ xDefault = $ this -> xConfig -> getOption ( 'upload.default.max-size' , 0 ) ; $ iSize = $ this -> xConfig -> getOption ( 'upload.files.' . $ sName . '.max-size' , $ xDefault ) ; if ( $ iSize > 0 && $ aUploadedFile [ 'size' ] > $ iSize ) { $ this -> sErrorMessage = $ this -> xTranslator -> trans ( 'errors.upload.max-size' , $ aUploadedFile ) ; return false ; } // Verify the min size $ xDefault = $ this -> xConfig -> getOption ( 'upload.default.min-size' , 0 ) ; $ iSize = $ this -> xConfig -> getOption ( 'upload.files.' . $ sName . '.min-size' , $ xDefault ) ; if ( $ iSize > 0 && $ aUploadedFile [ 'size' ] < $ iSize ) { $ this -> sErrorMessage = $ this -> xTranslator -> trans ( 'errors.upload.min-size' , $ aUploadedFile ) ; return false ; } return true ; }
Validate an uploaded file

@param string        $sName            The uploaded file variable name
@param array         $aUploadedFile    The file data received in the $_FILES array

@return bool            True if the file data are valid, and false if not
Validate an uploaded file