We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Надо вынести процедуру сохранения файла существующего в локальной файловой системе сервера в отдельный метод сервиса. см. https://www.cotonti.com/forums?m=posts&q=9374
т.е. это должно быть в отдельном методе:
// Путь к файлу локально $localFileName; $file = new File(); $file->original_name = $originalName; $file->user_id = $uid; $file->source = 'shop'; $file->source_id = $product->id; // ID сохраненного товара $file->ext = mb_strtolower(cot_filesGetExtension($fileData->fileName)); $file->mime_type = mime_content_type($localFileName); $file->is_img = 1; $file->size = filesize($localFileName)); Cot::$db->beginTransaction(); try { $fileId = $file->save(); if (!fileId) { throw new Exception('Ошибка при сохранении'); } // Path relative to files root directory $relativeFileName = FileService::generateFileRelativePath($objFile); $file->path = dirname($relativeFileName); $file->file_name = basename($relativeFileName); $file->filesystem_name = FileService::getFilesystemName($file->source, $file->source_field); // Path relative to site root directory $fileFullName = Cot::$cfg['files']['folder'] . '/' . $relativeFileName; if (!@rename($localFileName, $fileFullName)) { throw new Exception('Ошибка при сохранении'); } $file->save(); Cot::$db->commit(); } catch(\Throwable $e) { Cot::$db->rollBack(); // не удалось сохранить файл; } `` Который могут использовать разные контроллеры модуля или другие расширения.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Надо вынести процедуру сохранения файла существующего в локальной файловой системе сервера в отдельный метод сервиса.
см. https://www.cotonti.com/forums?m=posts&q=9374
т.е. это должно быть в отдельном методе:
The text was updated successfully, but these errors were encountered: