Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / files / controller / PhabricatorFileUploadDialogController.php
blob50af4656cb0f6522aad7922c208302686fb52a36
1 <?php
3 final class PhabricatorFileUploadDialogController
4 extends PhabricatorFileController {
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $request->getViewer();
9 $e_file = true;
10 $errors = array();
11 if ($request->isDialogFormPost()) {
12 $file_phids = $request->getStrList('filePHIDs');
13 if ($file_phids) {
14 $files = id(new PhabricatorFileQuery())
15 ->setViewer($viewer)
16 ->withPHIDs($file_phids)
17 ->setRaisePolicyExceptions(true)
18 ->execute();
19 } else {
20 $files = array();
23 if ($files) {
24 $results = array();
25 foreach ($files as $file) {
26 $results[] = $file->getDragAndDropDictionary();
29 $content = array(
30 'files' => $results,
33 return id(new AphrontAjaxResponse())->setContent($content);
34 } else {
35 $e_file = pht('Required');
36 $errors[] = pht('You must choose a file to upload.');
40 if ($request->getURIData('single')) {
41 $allow_multiple = false;
42 } else {
43 $allow_multiple = true;
46 $form = id(new AphrontFormView())
47 ->appendChild(
48 id(new PHUIFormFileControl())
49 ->setName('filePHIDs')
50 ->setLabel(pht('Upload File'))
51 ->setAllowMultiple($allow_multiple)
52 ->setError($e_file));
54 return $this->newDialog()
55 ->setTitle(pht('File'))
56 ->setErrors($errors)
57 ->appendForm($form)
58 ->addSubmitButton(pht('Upload'))
59 ->addCancelButton('/');