public function processUpload($filenameProcessor, $useProcessorForName, $field = null)
    {
    	if (!($filenameProcessor instanceof UploadFilenameProcessor))
    	{
    		throw new UploadUtilException("processUpload must receive a UploadFilenameProcessor class");
    	}
    	else if (is_null($field))
    	{
    		$ret = array();
			foreach($_FILES as $file => $property)
			{
				$ret[] = $this->processUpload($filenameProcessor, $useProcessorForName, $property);
			}
			return $ret;
		}
		else if (is_string($field))
		{
			$ret = array();
			$ret[] = $this->processUpload($filenameProcessor, $useProcessorForName, $_FILES[$field]);
			return $ret;
		}
		else if (is_array($field))
		{
			if ($useProcessorForName)
			{
				$uploadfile = $filenameProcessor->FullQualifiedNameAndPath();
			}
			else
			{
				$uploadfile = $filenameProcessor->PathSuggested() . FileUtil::Slash() . $field["name"];
			}
			if (move_uploaded_file($field['tmp_name'], $uploadfile))
			{
				return $uploadfile;
			}
			else
			{
				$message = "Unknow error: " . $field['error'];
				switch ($field['error'])
				{
					case UPLOAD_ERR_CANT_WRITE:
						$message = "Can't write";
						break;
					case UPLOAD_ERR_EXTENSION:
						$message = "Extension is not permitted";
						break;
					case UPLOAD_ERR_FORM_SIZE:
						$message = "Max post size reached";
						break;
					case UPLOAD_ERR_INI_SIZE:
						$message = "Max system size reached";
						break;
					case UPLOAD_ERR_NO_FILE:
						$message = "No file was uploaded";
						break;
					case UPLOAD_ERR_NO_TMP_DIR:
						$message = "No temp dir";
						break;
					case UPLOAD_ERR_PARTIAL:
						$message = "The uploaded file was only partially uploaded";
						break;
				}
			    throw new UploadUtilException($message);
			}
		}
		else
		{
			throw new UploadUtilException("Something is wrong with Upload file.");
		}
    }
public function processUpload($filenameProcessor, $useProcessorForName, $field = null)
    {
    	if (!($filenameProcessor instanceof UploadFilenameProcessor))
    	{
    		throw new UploadUtilException("processUpload must receive a UploadFilenameProcessor class");
    	}
    	else if (is_null($field))
    	{
    		$ret = array();
			foreach($_FILES as $file => $property)
			{
				$ret[] = $this->processUpload($filenameProcessor, $useProcessorForName, $property);
			}
			return $ret;
		}
		else if (is_string($field))
		{
			$ret = array();
			$ret[] = $this->processUpload($filenameProcessor, $useProcessorForName, $_FILES[$field]);
			return $ret;
		}
		else if (is_array($field))
		{
			if ($useProcessorForName)
			{
				$uploadfile = $filenameProcessor->FullQualifiedNameAndPath();
			}
			else
			{
				$uploadfile = $filenameProcessor->PathSuggested() . FileUtil::Slash() . $field["name"];
			}
			if (move_uploaded_file($field['tmp_name'], $uploadfile))
			{
				return $uploadfile;
			}
			else
			{
				$message = "Unknow error: " . $field['error'];
				switch ($field['error'])
				{
					case UPLOAD_ERR_CANT_WRITE:
						$message = "Can't write";
						break;
					case UPLOAD_ERR_EXTENSION:
						$message = "Extension is not permitted";
						break;
					case UPLOAD_ERR_FORM_SIZE:
						$message = "Max post size reached";
						break;
					case UPLOAD_ERR_INI_SIZE:
						$message = "Max system size reached";
						break;
					case UPLOAD_ERR_NO_FILE:
						$message = "No file was uploaded";
						break;
					case UPLOAD_ERR_NO_TMP_DIR:
						$message = "No temp dir";
						break;
					case UPLOAD_ERR_PARTIAL:
						$message = "The uploaded file was only partially uploaded";
						break;
				}
			    throw new UploadUtilException($message);
			}
		}
		else
		{
			throw new UploadUtilException("Something is wrong with Upload file.");
		}
    }
public function processUpload ( $ filenameProcessor , $ useProcessorForName , $ field = null ) { if ( ! ( $ filenameProcessor instanceof UploadFilenameProcessor ) ) { throw new UploadUtilException ( "processUpload must receive a UploadFilenameProcessor class" ) ; } else if ( is_null ( $ field ) ) { $ ret = array ( ) ; foreach ( $ _FILES as $ file => $ property ) { $ ret [ ] = $ this -> processUpload ( $ filenameProcessor , $ useProcessorForName , $ property ) ; } return $ ret ; } else if ( is_string ( $ field ) ) { $ ret = array ( ) ; $ ret [ ] = $ this -> processUpload ( $ filenameProcessor , $ useProcessorForName , $ _FILES [ $ field ] ) ; return $ ret ; } else if ( is_array ( $ field ) ) { if ( $ useProcessorForName ) { $ uploadfile = $ filenameProcessor -> FullQualifiedNameAndPath ( ) ; } else { $ uploadfile = $ filenameProcessor -> PathSuggested ( ) . FileUtil :: Slash ( ) . $ field [ "name" ] ; } if ( move_uploaded_file ( $ field [ 'tmp_name' ] , $ uploadfile ) ) { return $ uploadfile ; } else { $ message = "Unknow error: " . $ field [ 'error' ] ; switch ( $ field [ 'error' ] ) { case UPLOAD_ERR_CANT_WRITE : $ message = "Can't write" ; break ; case UPLOAD_ERR_EXTENSION : $ message = "Extension is not permitted" ; break ; case UPLOAD_ERR_FORM_SIZE : $ message = "Max post size reached" ; break ; case UPLOAD_ERR_INI_SIZE : $ message = "Max system size reached" ; break ; case UPLOAD_ERR_NO_FILE : $ message = "No file was uploaded" ; break ; case UPLOAD_ERR_NO_TMP_DIR : $ message = "No temp dir" ; break ; case UPLOAD_ERR_PARTIAL : $ message = "The uploaded file was only partially uploaded" ; break ; } throw new UploadUtilException ( $ message ) ; } } else { throw new UploadUtilException ( "Something is wrong with Upload file." ) ; } }
Process a document Upload

@param UploadFilenameProcessor $filenameProcessor
@param bool $useProcessorForName
@param string|array $field Contain the filename properties (if Array, or $filename if string)
@param array Valid Extensions
@return Array Filename saved.
Process a document Upload