code: public function changeFolder(HTTPRequest $request)
      {
          // CSRF check
          $token = $this->getForm()->getSecurityToken();
          if (!$token->checkRequest($request)) {
              return $this->httpError(400);
          }
          $folderID = $request->postVar('FolderID');
          if ($folderID) {
              $this->FolderSelector()->setLastFolderID($folderID);
          }
      }
docs: process HTTP request to change the upload folder
  
  @param HTTPRequest $request
  @throws HTTPResponse_Exception