public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); if ($request->isFormPost()) { $file = PhabricatorFile::newFromPHPUpload(idx($_FILES, 'file'), array('name' => $request->getStr('name'), 'authorPHID' => $user->getPHID())); return id(new AphrontRedirectResponse())->setURI($file->getBestURI()); } $panel = new PhabricatorFileUploadView(); $panel->setUser($user); return $this->buildStandardPageResponse(array($panel), array('title' => 'Upload File')); }
private function renderUploadPanel() { $request = $this->getRequest(); $user = $request->getUser(); $limit_text = PhabricatorFileUploadView::renderUploadLimit(); if ($this->useBasicUploader()) { $upload_panel = new PhabricatorFileUploadView(); $upload_panel->setUser($user); } else { require_celerity_resource('files-css'); $upload_id = celerity_generate_unique_node_id(); $panel_id = celerity_generate_unique_node_id(); $upload_panel = new AphrontPanelView(); $upload_panel->setHeader('Upload Files'); $upload_panel->setCaption($limit_text); $upload_panel->setCreateButton('Basic Uploader', $request->getRequestURI()->setQueryParam('basic_uploader', true)); $upload_panel->setWidth(AphrontPanelView::WIDTH_FULL); $upload_panel->setID($panel_id); $upload_panel->appendChild(phutil_render_tag('div', array('id' => $upload_id, 'style' => 'display: none;', 'class' => 'files-drag-and-drop'), '')); Javelin::initBehavior('files-drag-and-drop', array('uri' => '/file/dropupload/', 'browseURI' => '/file/filter/my/', 'control' => $upload_id, 'target' => $panel_id, 'activatedClass' => 'aphront-panel-view-drag-and-drop')); } return $upload_panel; }