• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/uf/controller.php
  • Класс: BitrixDiskUfController
  • Вызов: Controller::processActionUploadFileMobileImport
protected function processActionUploadFileMobileImport($storageId, $folderId = null)
{
	$storage = Storage::loadById($storageId);
	if(!$storage)
	{
		$this->errorCollection[] = new Error(
			"Could not find storage by id {$storageId}",
			self::ERROR_COULD_NOT_FIND_STORAGE
		);
		$this->sendJsonErrorResponse();
	}

	if(!$folderId)
	{
		$folder = $storage->getRootObject();
	}
	else
	{
		$folder = Folder::loadById($folderId);
		if(!$folder)
		{
			$this->errorCollection[] = new Error(
				Loc::getMessage('DISK_UF_CONTROLLER_ERROR_COULD_NOT_FIND_FIND_FOLDER'),
				self::ERROR_COULD_NOT_FIND_FOLDER
			);
			$this->sendJsonErrorResponse();
		}
	}

	$securityContext = $folder->getStorage()->getCurrentUserSecurityContext();
	if(!$folder->canAdd($securityContext))
	{
		$this->sendJsonAccessDeniedResponse();
	}

	if(!$this->checkRequiredFilesParams(array('file')))
	{
		$this->sendJsonErrorResponse();
	}

	$fileArray = $this->request->getFile('file');
	$newFile = $folder->uploadFile(
		$fileArray,
		array(
			'NAME' => Text::correctFilename($fileArray['name']),
			'CREATED_BY' => $this->getUser()->getId(),
		),
		array(),
		true
	);

	if(!$newFile)
	{
		$this->errorCollection->add($folder->getErrors());
		$this->sendJsonErrorResponse();
	}

	$this->sendJsonSuccessResponse();
}