76 lines
2.9 KiB
PHP
76 lines
2.9 KiB
PHP
<?php
|
|
include 'header.php';
|
|
|
|
// Protected page
|
|
if (!isset($_SESSION['user_email'])) {
|
|
header('Location: login.php');
|
|
exit;
|
|
}
|
|
|
|
$message = '';
|
|
$message_type = ''; // 'success' or 'danger'
|
|
|
|
// Handle file upload
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['xmlfile'])) {
|
|
$file = $_FILES['xmlfile'];
|
|
|
|
// Check for upload errors
|
|
if ($file['error'] !== UPLOAD_ERR_OK) {
|
|
$message = 'An error occurred during file upload. Please try again.';
|
|
$message_type = 'danger';
|
|
} else {
|
|
// Check file extension
|
|
$file_extension = pathinfo($file['name'], PATHINFO_EXTENSION);
|
|
if (strtolower($file_extension) !== 'xml') {
|
|
$message = 'Invalid file type. Only .xml files are allowed.';
|
|
$message_type = 'danger';
|
|
} else {
|
|
// In a real application, you would move the file to a permanent location
|
|
// and process it. For now, we just show a success message.
|
|
// move_uploaded_file($file['tmp_name'], 'uploads/' . basename($file['name']));
|
|
|
|
$message = '<strong>Success!</strong> Your file "' . htmlspecialchars(basename($file['name'])) . '" has been uploaded and is pending validation.';
|
|
$message_type = 'success';
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
|
|
<div class="container mt-5">
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-8">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h2>Submit a new Report</h2>
|
|
</div>
|
|
<div class="card-body">
|
|
<p class="card-text">Please select the E-PRTR XML report file you wish to submit. The file will be validated against the required schema before being processed.</p>
|
|
|
|
<?php if ($message): ?>
|
|
<div class="alert alert-<?php echo $message_type; ?>">
|
|
<?php echo $message; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<form action="upload.php" method="post" enctype="multipart/form-data">
|
|
<div class="mb-3">
|
|
<label for="xmlfile" class="form-label">XML Report File</label>
|
|
<input class="form-control" type="file" id="xmlfile" name="xmlfile" accept=".xml" required>
|
|
</div>
|
|
<div class="d-grid">
|
|
<button type="submit" class="btn btn-primary btn-lg">
|
|
<i class="bi bi-upload me-2"></i>Upload and Validate
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<div class="text-center mt-3">
|
|
<a href="dashboard.php"><i class="bi bi-arrow-left-circle"></i> Back to Dashboard</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php include 'footer.php'; ?>
|