- Модуль: disk
- Путь к файлу: ~/bitrix/modules/disk/lib/controller/content.php
- Класс: BitrixDiskControllerContent
- Вызов: Content::uploadAction
public function uploadAction($filename, $token = null)
{
if ($_SERVER['CONTENT_LENGTH'] >
min(CUtil::unformat(ini_get('upload_max_filesize')), CUtil::unformat(ini_get('post_max_size'))))
{
$this->errorCollection[] = new Error(
'The content length is too big to process request.', self::ERROR_COULD_TOO_BIG_REQUEST
);
return;
}
list($startRange, $endRange, $fileSize) = $this->getContentRange();
if (($startRange === null || $startRange === 0) && $token)
{
$this->errorCollection[] = new Error('You have to send Content-Range header to continue upload');
return;
}
$tmpFileArray = $this->getTmpFileArrayByInput();
$tmpFileManager = new Bitrix24DiskUploadFileManager();
$tmpFileManager
->setTmpFileClass(DiskDocumentCloudImportTmpFile::class)
->setToken($token)
->setUser($this->getCurrentUser()->getId())
->setFileSize($fileSize)
->setContentRange([$startRange, $endRange])
;
if (!$tmpFileManager->upload($filename, $tmpFileArray))
{
$this->errorCollection->add($tmpFileManager->getErrors());
return;
}
return [
'token' => $tmpFileManager->getToken(),
];
}