64 public function getFiles(array $savedFiles = [], array $files = [])
69 $newFiles = array_merge($newFiles, $this->
getPosted());
70 foreach($newFiles as $file)
84 $result = array_merge($result, $this->
getExisted($files));
86 $filesToDelete = array_diff($savedFiles, $result);
87 $filesToDelete = array_merge($this->
getDeleted(), $filesToDelete);
88 $filesToDelete = array_unique($filesToDelete);
89 foreach ($filesToDelete as $fileId)
91 \CFile::Delete($fileId);
122 $fileList = $this->request->getFile($this->inputName);
123 if(!is_array($fileList))
128 foreach($fileList as $attribute => $files)
130 if(!is_array($files))
135 foreach($files as $index => $value)
137 $result[$index][$attribute] = $value;
141 foreach($result as $index => $file)
143 if(!is_uploaded_file($file[
"tmp_name"]))
145 unset($result[$index]);
165 $files = $this->request->get($this->inputName);
167 if(!is_array($files))
172 foreach($files as $index => $value)
174 if (is_string($value) && preg_match(
"/^https?:\\/\\//", $value))
176 $result[$index] = \CFile::MakeFileArray($value);
182 $filePath = $value[
'tmp_name'];
191 if(is_null($checkResult))
196 if($checkResult[
'isSuccess'])
198 $io = \CBXVirtualIo::GetInstance();
199 $result[$index] = \CFile::MakeFileArray($io->GetPhysicalName($checkResult[
'absPath']));
202 $result[$index][
'name'] = $value[
'name'];
219 $isCheckedSuccess =
false;
220 $io = \CBXVirtualIo::GetInstance();
222 if(mb_strpos($filePath, \CTempFile::GetAbsoluteRoot()) === 0)
224 $absPath = $filePath;
226 elseif(mb_strpos($io->CombinePath($docRoot, $filePath), \CTempFile::GetAbsoluteRoot()) === 0)
228 $absPath = $io->CombinePath($docRoot, $filePath);
232 $absPath = $io->CombinePath(\CTempFile::GetAbsoluteRoot(), $filePath);
233 $isCheckedSuccess =
true;
236 $absPath = realpath(str_replace(
"\\",
"/", $absPath));
237 if (mb_strpos($absPath, realpath(\CTempFile::GetAbsoluteRoot())) !== 0)
242 if (!$isCheckedSuccess && $io->ValidatePathString($absPath) && $io->FileExists($absPath))
244 $docRoot = $io->CombinePath($docRoot,
'/');
245 $relPath = str_replace($docRoot,
'', $absPath);
246 $perm =
$GLOBALS[
'APPLICATION']->GetFileAccessPermission($relPath);
249 $isCheckedSuccess =
true;
254 'isSuccess' => $isCheckedSuccess,
255 'absPath' => $absPath
271 $files = $this->request->get($this->inputName);
273 if(!is_array($files))
278 foreach($files as $index => $value)
280 if (!is_numeric($index) || !is_numeric($value))
285 $file = \CFile::getByID($value)->fetch();
286 if (!$file || $file[
'MODULE_ID'] !==
'sender')
291 $result[] = (int) $value;
305 if($file[
"name"] ==
'' || intval($file[
"size"]) <= 0)
310 $pathHash = md5($file[
"tmp_name"]);
311 $sessionKey =
'sender_post_files';
312 if (!empty($_SESSION[$sessionKey][$pathHash]))
314 $fileId = (int) $_SESSION[$sessionKey][$pathHash];
315 return $fileId ?:
null;
318 $file[
"MODULE_ID"] =
"sender";
319 $fileId = (int) \CFile::saveFile($file,
"sender",
true);
322 $_SESSION[$sessionKey][$pathHash] = $fileId;