60 lines
2.8 KiB
PHP
60 lines
2.8 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Upload Status</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css">
|
|
</head>
|
|
<body>
|
|
<div class="container d-flex justify-content-center align-items-center vh-100">
|
|
<div class="card text-center shadow-sm p-4">
|
|
<div class="card-body">
|
|
<?php
|
|
$target_dir = "uploads/";
|
|
if (!is_dir($target_dir)) {
|
|
mkdir($target_dir, 0755, true);
|
|
}
|
|
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
|
|
$uploadOk = 1;
|
|
$fileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
|
|
|
|
// Check if file was uploaded
|
|
if (isset($_POST["submit"])) {
|
|
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
|
|
if ($check !== false) {
|
|
$uploadOk = 1;
|
|
} else {
|
|
$uploadOk = 0;
|
|
}
|
|
}
|
|
|
|
// Allow certain file formats
|
|
if ($fileType != "jpg" && $fileType != "png" && $fileType != "jpeg" && $fileType != "pdf" && $fileType != "pptx") {
|
|
echo "<h2 class\"text-danger\">Sorry, only JPG, JPEG, PNG, PDF & PPTX files are allowed.</h2>";
|
|
$uploadOk = 0;
|
|
}
|
|
|
|
// Check if $uploadOk is set to 0 by an error
|
|
if ($uploadOk == 0) {
|
|
echo "<p class=\"text-muted\">Your file was not uploaded.</p>";
|
|
// if everything is ok, try to upload file
|
|
} else {
|
|
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
|
|
echo "<h2 class=\"text-success\">The file ". htmlspecialchars(basename($_FILES["fileToUpload"]["name"])) ." has been uploaded.</h2>";
|
|
echo "<p class=\"text-muted\">We are now processing your file. You will be redirected shortly.</p>";
|
|
// In a real app, you would redirect to the material preview page, e.g.:
|
|
// header("Location: material_preview.php?file=" . urlencode(basename( $_FILES["fileToUpload"]["name"]))));
|
|
} else {
|
|
echo "<h2 class=\"text-danger\">Sorry, there was an error uploading your file.</h2>";
|
|
}
|
|
}
|
|
?>
|
|
<a href="index.php" class="btn btn-primary mt-3">Back to Home</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|