1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-23 02:38:48 +02:00
phorge-phorge/src/applications/files/controller/PhabricatorFileDropUploadController.php

36 lines
854 B
PHP
Raw Normal View History

<?php
final class PhabricatorFileDropUploadController
extends PhabricatorFileController {
/**
* @phutil-external-symbol class PhabricatorStartup
*/
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
// NOTE: Throws if valid CSRF token is not present in the request.
$request->validateCSRF();
$data = PhabricatorStartup::getRawInput();
$name = $request->getStr('name');
$file = PhabricatorFile::newFromXHRUpload(
$data,
array(
'name' => $request->getStr('name'),
'authorPHID' => $user->getPHID(),
'isExplicitUpload' => true,
));
return id(new AphrontAjaxResponse())->setContent(
array(
'id' => $file->getID(),
'phid' => $file->getPHID(),
'uri' => $file->getBestURI(),
));
}
}