- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/lib/ui/uploader/uploader.php
- Класс: BitrixMainUIUploaderUploader
- Вызов: Uploader::checkPost
public function checkPost($checkPost = true)
{
if ($checkPost === false && !is_array($this->request->getQuery(self::INFO_NAME)) ||
$checkPost !== false && !is_array($this->request->getPost(self::INFO_NAME)))
return false;
if ($checkPost === false)
$this->setRequestMethodToCheck(array("get"));
try
{
$this->fillRequireData();
$cid = FileInputUtility::instance()->registerControl($this->getRequest("CID"), $this->controlId);
if ($this->mode == "upload")
{
$package = new Package(
$this->path,
$cid,
$this->getRequest("packageIndex")
);
$package
->setStorage($this->params["storage"])
->setCopies($this->params["copies"]);
$response = $package->checkPost($this->params);
if ($this->version <= 1)
{
$response2 = array();
foreach ($response as $k => $r)
{
$response2[$k] = array(
"hash" => $r["hash"],
"status" => $r["status"],
"file" => $r
);
if (isset($r["error"]))
$response2[$k]["error"] = $r["error"];
}
$result = array(
"status" => $package->getLog("uploadStatus") == "uploaded" ? "done" : "inprogress",
"package" => array(
$package->getIndex() => array_merge(
$package->getLog(),
array(
"executed" => $package->getLog("executeStatus") == "executed",
"filesCount" => $package->getLog("filesCount")
)
)
),
"report" => array(
"uploading" => array(
$package->getCid() => $package->getCidLog()
)
),
"files" => self::prepareData($response2)
);
$this->showJsonAnswer($result);
}
}
else if ($this->mode == "delete")
{
$cid = FileInputUtility::instance()->registerControl($this->getRequest("CID"), $this->controlId);
File::deleteFile($cid, $this->getRequest("hash"), $this->path);
}
else
{
File::viewFile($cid, $this->getRequest("hash"), $this->path);
}
return true;
}
catch (MainIOIoException $e)
{
$this->showJsonAnswer(array(
"status" => "error",
"error" => "Something went wrong with the temporary file."
));
}
catch (Exception $e)
{
$this->showJsonAnswer(array(
"status" => "error",
"error" => $e->getMessage()
));
}
return false;
}