public function upload($file, $to = null)
    {
        if ($this->test($file)) {
            if (null === $to) {
                $to = $file['name'];
            }
            if (!$this->overwrite) {
                $to = $this->checkFilename($to);
            }

            $this->uploadedFile = $to;
            $to = $this->uploadDir . DIRECTORY_SEPARATOR . $to;

            // Move the uploaded file, creating a file object with it.
            if (move_uploaded_file($file['tmp_name'], $to)) {
                return $this->uploadedFile;
            } else {
                $this->error = self::UPLOAD_ERR_UNEXPECTED;
                return false;
            }
        } else {
            return false;
        }

    }
public function upload($file, $to = null)
    {
        if ($this->test($file)) {
            if (null === $to) {
                $to = $file['name'];
            }
            if (!$this->overwrite) {
                $to = $this->checkFilename($to);
            }

            $this->uploadedFile = $to;
            $to = $this->uploadDir . DIRECTORY_SEPARATOR . $to;

            // Move the uploaded file, creating a file object with it.
            if (move_uploaded_file($file['tmp_name'], $to)) {
                return $this->uploadedFile;
            } else {
                $this->error = self::UPLOAD_ERR_UNEXPECTED;
                return false;
            }
        } else {
            return false;
        }

    }
public function upload ( $ file , $ to = null ) { if ( $ this -> test ( $ file ) ) { if ( null === $ to ) { $ to = $ file [ 'name' ] ; } if ( ! $ this -> overwrite ) { $ to = $ this -> checkFilename ( $ to ) ; } $ this -> uploadedFile = $ to ; $ to = $ this -> uploadDir . DIRECTORY_SEPARATOR . $ to ; // Move the uploaded file, creating a file object with it. if ( move_uploaded_file ( $ file [ 'tmp_name' ] , $ to ) ) { return $ this -> uploadedFile ; } else { $ this -> error = self :: UPLOAD_ERR_UNEXPECTED ; return false ; } } else { return false ; } }
Upload file to the upload dir, returns the newly uploaded file

@param  array  $file
@param  string $to
@return mixed
Upload file to the upload dir returns the newly uploaded file