public function httpPOST(RequestInterface $request, ResponseInterface $response)
    {
        $contentType = $request->getHeader('Content-Type');
        list($contentType) = explode(';', $contentType);
        if ('application/x-www-form-urlencoded' !== $contentType &&
            'multipart/form-data' !== $contentType) {
            return;
        }
        $postVars = $request->getPostData();

        if (!isset($postVars['sabreAction'])) {
            return;
        }

        $uri = $request->getPath();

        if ($this->server->emit('onBrowserPostAction', [$uri, $postVars['sabreAction'], $postVars])) {
            switch ($postVars['sabreAction']) {
                case 'mkcol':
                    if (isset($postVars['name']) && trim($postVars['name'])) {
                        // Using basename() because we won't allow slashes
                        list(, $folderName) = Uri\split(trim($postVars['name']));

                        if (isset($postVars['resourceType'])) {
                            $resourceType = explode(',', $postVars['resourceType']);
                        } else {
                            $resourceType = ['{DAV:}collection'];
                        }

                        $properties = [];
                        foreach ($postVars as $varName => $varValue) {
                            // Any _POST variable in clark notation is treated
                            // like a property.
                            if ('{' === $varName[0]) {
                                // PHP will convert any dots to underscores.
                                // This leaves us with no way to differentiate
                                // the two.
                                // Therefore we replace the string *DOT* with a
                                // real dot. * is not allowed in uris so we
                                // should be good.
                                $varName = str_replace('*DOT*', '.', $varName);
                                $properties[$varName] = $varValue;
                            }
                        }

                        $mkCol = new MkCol(
                            $resourceType,
                            $properties
                        );
                        $this->server->createCollection($uri.'/'.$folderName, $mkCol);
                    }
                    break;

                // @codeCoverageIgnoreStart
                case 'put':

                    if ($_FILES) {
                        $file = current($_FILES);
                    } else {
                        break;
                    }

                    list(, $newName) = Uri\split(trim($file['name']));
                    if (isset($postVars['name']) && trim($postVars['name'])) {
                        $newName = trim($postVars['name']);
                    }

                    // Making sure we only have a 'basename' component
                    list(, $newName) = Uri\split($newName);

                    if (is_uploaded_file($file['tmp_name'])) {
                        $this->server->createFile($uri.'/'.$newName, fopen($file['tmp_name'], 'r'));
                    }
                    break;
                // @codeCoverageIgnoreEnd
            }
        }
        $response->setHeader('Location', $request->getUrl());
        $response->setStatus(302);

        return false;
    }
public function httpPOST(RequestInterface $request, ResponseInterface $response)
    {
        $contentType = $request->getHeader('Content-Type');
        list($contentType) = explode(';', $contentType);
        if ('application/x-www-form-urlencoded' !== $contentType &&
            'multipart/form-data' !== $contentType) {
            return;
        }
        $postVars = $request->getPostData();

        if (!isset($postVars['sabreAction'])) {
            return;
        }

        $uri = $request->getPath();

        if ($this->server->emit('onBrowserPostAction', [$uri, $postVars['sabreAction'], $postVars])) {
            switch ($postVars['sabreAction']) {
                case 'mkcol':
                    if (isset($postVars['name']) && trim($postVars['name'])) {
                        // Using basename() because we won't allow slashes
                        list(, $folderName) = Uri\split(trim($postVars['name']));

                        if (isset($postVars['resourceType'])) {
                            $resourceType = explode(',', $postVars['resourceType']);
                        } else {
                            $resourceType = ['{DAV:}collection'];
                        }

                        $properties = [];
                        foreach ($postVars as $varName => $varValue) {
                            // Any _POST variable in clark notation is treated
                            // like a property.
                            if ('{' === $varName[0]) {
                                // PHP will convert any dots to underscores.
                                // This leaves us with no way to differentiate
                                // the two.
                                // Therefore we replace the string *DOT* with a
                                // real dot. * is not allowed in uris so we
                                // should be good.
                                $varName = str_replace('*DOT*', '.', $varName);
                                $properties[$varName] = $varValue;
                            }
                        }

                        $mkCol = new MkCol(
                            $resourceType,
                            $properties
                        );
                        $this->server->createCollection($uri.'/'.$folderName, $mkCol);
                    }
                    break;

                // @codeCoverageIgnoreStart
                case 'put':

                    if ($_FILES) {
                        $file = current($_FILES);
                    } else {
                        break;
                    }

                    list(, $newName) = Uri\split(trim($file['name']));
                    if (isset($postVars['name']) && trim($postVars['name'])) {
                        $newName = trim($postVars['name']);
                    }

                    // Making sure we only have a 'basename' component
                    list(, $newName) = Uri\split($newName);

                    if (is_uploaded_file($file['tmp_name'])) {
                        $this->server->createFile($uri.'/'.$newName, fopen($file['tmp_name'], 'r'));
                    }
                    break;
                // @codeCoverageIgnoreEnd
            }
        }
        $response->setHeader('Location', $request->getUrl());
        $response->setStatus(302);

        return false;
    }
public function httpPOST ( RequestInterface $ request , ResponseInterface $ response ) { $ contentType = $ request -> getHeader ( 'Content-Type' ) ; list ( $ contentType ) = explode ( ';' , $ contentType ) ; if ( 'application/x-www-form-urlencoded' !== $ contentType && 'multipart/form-data' !== $ contentType ) { return ; } $ postVars = $ request -> getPostData ( ) ; if ( ! isset ( $ postVars [ 'sabreAction' ] ) ) { return ; } $ uri = $ request -> getPath ( ) ; if ( $ this -> server -> emit ( 'onBrowserPostAction' , [ $ uri , $ postVars [ 'sabreAction' ] , $ postVars ] ) ) { switch ( $ postVars [ 'sabreAction' ] ) { case 'mkcol' : if ( isset ( $ postVars [ 'name' ] ) && trim ( $ postVars [ 'name' ] ) ) { // Using basename() because we won't allow slashes list ( , $ folderName ) = Uri \ split ( trim ( $ postVars [ 'name' ] ) ) ; if ( isset ( $ postVars [ 'resourceType' ] ) ) { $ resourceType = explode ( ',' , $ postVars [ 'resourceType' ] ) ; } else { $ resourceType = [ '{DAV:}collection' ] ; } $ properties = [ ] ; foreach ( $ postVars as $ varName => $ varValue ) { // Any _POST variable in clark notation is treated // like a property. if ( '{' === $ varName [ 0 ] ) { // PHP will convert any dots to underscores. // This leaves us with no way to differentiate // the two. // Therefore we replace the string *DOT* with a // real dot. * is not allowed in uris so we // should be good. $ varName = str_replace ( '*DOT*' , '.' , $ varName ) ; $ properties [ $ varName ] = $ varValue ; } } $ mkCol = new MkCol ( $ resourceType , $ properties ) ; $ this -> server -> createCollection ( $ uri . '/' . $ folderName , $ mkCol ) ; } break ; // @codeCoverageIgnoreStart case 'put' : if ( $ _FILES ) { $ file = current ( $ _FILES ) ; } else { break ; } list ( , $ newName ) = Uri \ split ( trim ( $ file [ 'name' ] ) ) ; if ( isset ( $ postVars [ 'name' ] ) && trim ( $ postVars [ 'name' ] ) ) { $ newName = trim ( $ postVars [ 'name' ] ) ; } // Making sure we only have a 'basename' component list ( , $ newName ) = Uri \ split ( $ newName ) ; if ( is_uploaded_file ( $ file [ 'tmp_name' ] ) ) { $ this -> server -> createFile ( $ uri . '/' . $ newName , fopen ( $ file [ 'tmp_name' ] , 'r' ) ) ; } break ; // @codeCoverageIgnoreEnd } } $ response -> setHeader ( 'Location' , $ request -> getUrl ( ) ) ; $ response -> setStatus ( 302 ) ; return false ; }
Handles POST requests for tree operations.

@param RequestInterface  $request
@param ResponseInterface $response

@return bool
Handles POST requests for tree operations .