Skip to content

Instantly share code, notes, and snippets.

@sidor1989
Created October 24, 2019 13:22
Show Gist options
  • Save sidor1989/e6fb9c47f01706a96492c8bec1e77167 to your computer and use it in GitHub Desktop.
Save sidor1989/e6fb9c47f01706a96492c8bec1e77167 to your computer and use it in GitHub Desktop.
<?
$info = new SplFileInfo($step_details[1]); // подставляю путь файла и узнаю его инфу
$ext = '.'.pathinfo($info->getFilename(), PATHINFO_EXTENSION);
$file = $name.$ext;
if( file_exists( DIR.$file ) && !file_exists( DIR.$name.$key.$ext )) // проверки на существующие файлы
$file = $name.$key.$ext;
else
$file = $name.($key+1).$ext;
save_img( DIR.$file, $step_details[1]); // сохраняю файл на сервере
$arFile = CFile::MakeFileArray( DIR.$file ); // создаю новый
$arFile['del'] = 'Y'; // метка удаления временного
$arFile['MODULE_ID'] = 'main';
$fid = CFile::SaveFile($arFile, 'recipes');
(int) $fid ? $img_steps[$key] = (int) $fid : '';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment