logToFile("=== Documents Upload Started ==="); $this->logToFile("REQUEST_URI: " . $_SERVER['REQUEST_URI']); $this->logToFile("REQUEST_METHOD: " . $_SERVER['REQUEST_METHOD']); $this->logToFile("Content-Type: " . ($_SERVER['CONTENT_TYPE'] ?? 'not set')); // Логируем данные запроса $this->logToFile("FILES data:", $_FILES); $this->logToFile("POST data:", $_POST); $this->logToFile("REQUEST data:", $request->getAll()); // Проверяем PHP настройки $this->logToFile("PHP Settings:", [ 'upload_max_filesize' => ini_get('upload_max_filesize'), 'post_max_size' => ini_get('post_max_size'), 'max_file_uploads' => ini_get('max_file_uploads'), 'file_uploads' => ini_get('file_uploads') ? 'On' : 'Off', 'max_execution_time' => ini_get('max_execution_time'), 'memory_limit' => ini_get('memory_limit') ]); // Проверяем права доступа к папкам $storagePath = '/var/www/fastuser/data/www/crm.clientright.ru/storage'; $this->logToFile("Storage permissions:", [ 'storage_exists' => file_exists($storagePath), 'storage_readable' => is_readable($storagePath), 'storage_writable' => is_writable($storagePath), 'storage_permissions' => substr(sprintf('%o', fileperms($storagePath)), -4) ]); try { // Вызываем родительский метод $this->logToFile("Calling parent::process()"); parent::process($request); // Если дошли сюда, значит все прошло успешно $this->logToFile("=== Documents Upload Completed Successfully ==="); } catch (Throwable $e) { $this->logToFile("=== Documents Upload Error ==="); $this->logToFile("Error: " . $e->getMessage()); $this->logToFile("File: " . $e->getFile() . " Line: " . $e->getLine()); $this->logToFile("Trace: " . $e->getTraceAsString()); // Всегда возвращаем JSON при ошибке header('Content-Type: application/json; charset=utf-8'); http_response_code(500); echo json_encode([ 'success' => false, 'error' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'timestamp' => date('Y-m-d H:i:s') ], JSON_UNESCAPED_UNICODE); exit; } } public function checkPermission(Vtiger_Request $request) { $this->logToFile("Checking permissions"); return parent::checkPermission($request); } protected function saveRecord($request) { $this->logToFile("Starting saveRecord"); try { $recordModel = parent::saveRecord($request); $this->logToFile("Record saved successfully", [ 'record_id' => $recordModel->getId(), 'module' => $recordModel->getModuleName() ]); return $recordModel; } catch (Exception $e) { $this->logToFile("Error in saveRecord: " . $e->getMessage()); throw $e; } } } ?>