102 lines
4.3 KiB
HTML
102 lines
4.3 KiB
HTML
|
|
<!DOCTYPE html>
|
||
|
|
<html lang="ru">
|
||
|
|
<head>
|
||
|
|
<meta charset="UTF-8">
|
||
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
|
<title>Тест загрузки файлов CRM</title>
|
||
|
|
<style>
|
||
|
|
body { font-family: Arial, sans-serif; margin: 20px; }
|
||
|
|
.form-group { margin: 15px 0; }
|
||
|
|
label { display: block; margin-bottom: 5px; font-weight: bold; }
|
||
|
|
input[type="text"], input[type="file"] { width: 100%; padding: 8px; margin-bottom: 10px; }
|
||
|
|
button { background: #007cba; color: white; padding: 10px 20px; border: none; cursor: pointer; }
|
||
|
|
button:hover { background: #005a87; }
|
||
|
|
.result { margin-top: 20px; padding: 15px; border: 1px solid #ddd; background: #f9f9f9; }
|
||
|
|
.error { border-color: #dc3545; background: #f8d7da; color: #721c24; }
|
||
|
|
.success { border-color: #28a745; background: #d4edda; color: #155724; }
|
||
|
|
</style>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
<h1>Тест загрузки файлов в CRM</h1>
|
||
|
|
|
||
|
|
<form id="uploadForm" enctype="multipart/form-data">
|
||
|
|
<div class="form-group">
|
||
|
|
<label for="module">Модуль:</label>
|
||
|
|
<input type="text" id="module" name="module" value="Documents" readonly>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="form-group">
|
||
|
|
<label for="action">Действие:</label>
|
||
|
|
<input type="text" id="action" name="action" value="SaveWithLogging" readonly>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="form-group">
|
||
|
|
<label for="notes_title">Название документа:</label>
|
||
|
|
<input type="text" id="notes_title" name="notes_title" value="Тестовый документ" required>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="form-group">
|
||
|
|
<label for="filelocationtype">Тип хранения:</label>
|
||
|
|
<input type="text" id="filelocationtype" name="filelocationtype" value="I" readonly>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="form-group">
|
||
|
|
<label for="filename">Выберите файл:</label>
|
||
|
|
<input type="file" id="filename" name="filename" required>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<button type="submit">Загрузить файл</button>
|
||
|
|
</form>
|
||
|
|
|
||
|
|
<div id="result" class="result" style="display: none;"></div>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
document.getElementById('uploadForm').addEventListener('submit', function(e) {
|
||
|
|
e.preventDefault();
|
||
|
|
|
||
|
|
const formData = new FormData(this);
|
||
|
|
const resultDiv = document.getElementById('result');
|
||
|
|
|
||
|
|
resultDiv.style.display = 'block';
|
||
|
|
resultDiv.className = 'result';
|
||
|
|
resultDiv.innerHTML = 'Загрузка файла...';
|
||
|
|
|
||
|
|
fetch('index.php', {
|
||
|
|
method: 'POST',
|
||
|
|
body: formData
|
||
|
|
})
|
||
|
|
.then(response => {
|
||
|
|
console.log('Response status:', response.status);
|
||
|
|
console.log('Response headers:', response.headers);
|
||
|
|
|
||
|
|
if (response.headers.get('content-type')?.includes('application/json')) {
|
||
|
|
return response.json();
|
||
|
|
} else {
|
||
|
|
return response.text();
|
||
|
|
}
|
||
|
|
})
|
||
|
|
.then(data => {
|
||
|
|
console.log('Response data:', data);
|
||
|
|
|
||
|
|
if (typeof data === 'object') {
|
||
|
|
if (data.success === false) {
|
||
|
|
resultDiv.className = 'result error';
|
||
|
|
resultDiv.innerHTML = '<h3>Ошибка загрузки:</h3><pre>' + JSON.stringify(data, null, 2) + '</pre>';
|
||
|
|
} else {
|
||
|
|
resultDiv.className = 'result success';
|
||
|
|
resultDiv.innerHTML = '<h3>Успешно!</h3><pre>' + JSON.stringify(data, null, 2) + '</pre>';
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
resultDiv.className = 'result success';
|
||
|
|
resultDiv.innerHTML = '<h3>Ответ сервера:</h3><pre>' + data + '</pre>';
|
||
|
|
}
|
||
|
|
})
|
||
|
|
.catch(error => {
|
||
|
|
console.error('Error:', error);
|
||
|
|
resultDiv.className = 'result error';
|
||
|
|
resultDiv.innerHTML = '<h3>Ошибка:</h3><pre>' + error.message + '</pre>';
|
||
|
|
});
|
||
|
|
});
|
||
|
|
</script>
|
||
|
|
</body>
|
||
|
|
</html>
|