- Модуль: webdav
- Путь к файлу: ~/bitrix/modules/webdav/classes/diskstorage.php
- Класс: CDiskStorage
- Вызов: CDiskStorage::addFile
public function addFile($name, $targetDirectoryId, CWebDavTmpFile $tmpFile)
{
if(!$targetDirectoryId)
{
$folder = $this->storage->getRootObject();
}
else
{
$folder = Folder::loadById($targetDirectoryId);
}
if(!$folder)
{
$this->errorCollection->add(array(new Error("Could not " . __METHOD__ . " by id {$targetDirectoryId}", 11152)));
throw new WebDavStorageBreakDownException('bd addFile could not find folder');
}
if(!$folder->canAdd($this->storage->getCurrentUserSecurityContext()))
{
throw new CWebDavAccessDeniedException;
}
$fileArray = CFile::MakeFileArray($tmpFile->getAbsolutePath());
$fileArray['name'] = $name;
$fileModel = $folder->uploadFile($fileArray, array('NAME' => $name, 'CREATED_BY' => $this->getUser()->getId()));
if($fileModel)
{
$this->loadFormattedFolderTreeAndBreadcrumbs();
return $this->formatFileToResponse($fileModel);
}
$this->errorCollection->add(array(new Error("Could not " . __METHOD__ . ", uploadFile to {$targetDirectoryId}", 11153)));
$this->errorCollection->add($folder->getErrors());
throw new WebDavStorageBreakDownException('bd addFile');
}