Problem Solving
Problem Solving
Course Code and Course Name : 21UITC52 and Open Source Technology
Team Members:
S.No NAME OF THE STUDENT REGISTER NUMBER
1. B.DEEPA A11UIT001
2. M.KANMANI A11UIT003
3. M.KASTHURI A11UIT004
4. M.MADHU MITHA A11UIT005
5. N.MAHADEVI A11UIT006
6. G.MUNI PRIYA A11UIT007
Problem Description:
You build a exam apply portal ,You want to allow users to upload an image file, and
after the upload, you want to perform some basic processing, such as resizing the image and
saving it to the server.
Suggested Model:
Using move_uploaded_file
Proposed Solution:
Index.php:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Online Exam Registration</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f2f2f2;
}
header {
background-color: #002366;
color: white;
padding: 20px;
text-align: center;
}
.container {
width: 80%;
margin: 0 auto;
padding: 20px;
}
form {
background-color: #fff;
padding: 20px;
border-radius: 5px;
}
input[type="text"],
input[type="email"],
input[type="submit"] {
width: 100%;
padding: 10px;
margin-bottom: 10px;
border-radius: 5px;
border: 1px solid #ccc;
}
input[type="submit"] {
background-color: #002366;
color: white;
cursor: pointer;
}
</style>
</head>
<body>
<header>
<h1>Online Exam Registration</h1>
</header>
<div class="container">
<form action="uploads.php" method="POST" enctype="multipart/form-data">
<label for="fullname">Full Name:</label>
<input type="text" id="fullname" name="fullname" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<br><br>
<label for="exam_type">Exam Type:</label>
<select id="exam_type" name="exam_type">
<option value="IELTS">IELTS</option>
<option value="TOEFL">TOEFL</option>
<option value="GRE">GRE</option>
<option value="SAT">SAT</option>
<option value="NET">NET</option>
</select>
<br><br>
<label>ID Proof : </label>
<input type="file" name="image">
<br><br>
<label>Address:</label>
<input type="text" id="fullname" name="fullname" required>
<br>
<input type="submit" value="Register">
</form>
</div>
</body>
</html>
Uploads.php:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['submit'])) {
$target_dir = "uploads/"; // Directory where the image will be saved
$target_file = $target_dir . basename($_FILES["image"]["name"]); // Path to the uploaded
image
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
echo "The file " . basename($_FILES["image"]["name"]) . " has been uploaded and
resized.";
}
}
?>
Solution Output: