• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/rest/service/folder.php
  • Класс: BitrixDiskRestServiceFolder
  • Вызов: Folder::upload
protected function upload($id, array $data = array(), array $rights = array(), $generateUniqueName = false)
{
	$folder = $this->getFolderById($id);
	$securityContext = $folder->getStorage()->getCurrentUserSecurityContext();
	if(!$folder->canAdd($securityContext))
	{
		throw new AccessException;
	}
	if ($rights && !$folder->canChangeRights($securityContext))
	{
		throw new AccessException;
	}

	if(empty($_FILES[self::FILE_FORM_FIELD]))
	{
		$this->errorCollection[] = new Error("Error: required parameter " . self::FILE_FORM_FIELD, self::ERROR_REQUIRED_PARAMETER);

		return null;
	}

	$file = $folder->uploadFile($_FILES[self::FILE_FORM_FIELD], array(
		'NAME' => $_FILES[self::FILE_FORM_FIELD]['name'],
		'CREATED_BY' => $this->userId
	), $rights, $generateUniqueName);

	if(!$file)
	{
		$this->errorCollection->add($folder->getErrors());
		return null;
	}

	return $file;
}