I need, knowing the file id, to copy it into the same folder where the current script is running. I do this:

CFile::CopyFile($arFields["DETAIL_PICTURE"], true, $_SERVER["DOCUMENT_ROOT"].$APPLICATION->GetCurDir())

But the file is copied to the same folder, where it lies. What could be the problem?

  • the current script folder is __DIR__ , maybe it will be better this way - apelsinka223
  • @ apelsinka223, this option CFile::CopyFile($arFields["DETAIL_PICTURE"], true, __DIR__) also did not work - S.Ivanov
  • then specify the path by the string, it should work - Nikolaj Sarry

1 answer 1

Solved the problem this way:

 copy($_SERVER["DOCUMENT_ROOT"].CFile::GetPath($arFields["DETAIL_PICTURE"]), __DIR__."/images/".$arFields['ID']."/".$arFileDetail["FILE_NAME"]);