public function save($path,$name=null){
		if(!file_exists($path)){
			mkdir($path,0777,true);
		}

		$destinationPath=rtrim($path, '/');
		if($name){
			$destinationPath.='/'.$name;
		}
		else{
			$destinationPath.='/'.$this->name;
		}

		if(!copy($this->tmpName, $destinationPath)){
			//detect error reason
			$reason='Unknown';
			if(!file_exists($path)){
				$reason='Path "'.$path.'" not exists.';
			}
			else if(!is_writeable($path))
				$reason='Path "'.$path.'" required permission to write.';

			throw new FileFailSavedException($reason);
		}
	}
public function save($path,$name=null){
		if(!file_exists($path)){
			mkdir($path,0777,true);
		}

		$destinationPath=rtrim($path, '/');
		if($name){
			$destinationPath.='/'.$name;
		}
		else{
			$destinationPath.='/'.$this->name;
		}

		if(!copy($this->tmpName, $destinationPath)){
			//detect error reason
			$reason='Unknown';
			if(!file_exists($path)){
				$reason='Path "'.$path.'" not exists.';
			}
			else if(!is_writeable($path))
				$reason='Path "'.$path.'" required permission to write.';

			throw new FileFailSavedException($reason);
		}
	}
public function save ( $ path , $ name = null ) { if ( ! file_exists ( $ path ) ) { mkdir ( $ path , 0777 , true ) ; } $ destinationPath = rtrim ( $ path , '/' ) ; if ( $ name ) { $ destinationPath .= '/' . $ name ; } else { $ destinationPath .= '/' . $ this -> name ; } if ( ! copy ( $ this -> tmpName , $ destinationPath ) ) { //detect error reason $ reason = 'Unknown' ; if ( ! file_exists ( $ path ) ) { $ reason = 'Path "' . $ path . '" not exists.' ; } else if ( ! is_writeable ( $ path ) ) $ reason = 'Path "' . $ path . '" required permission to write.' ; throw new FileFailSavedException ( $ reason ) ; } }
Save uploaded file to destiny dir

@param string $path path dir to save file
@param string $name file name if is empty then set name on origin name
@throws FileFailSavedException
Save uploaded file to destiny dir