Mohamed Hammi
Posted on November 19, 2024
HTML Form
/index.html
:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<form method="post" action="upload.php" enctype="multipart/form-data">
<label for="file-label">File : </label>
<input type="file" name="myfile" id="myfile" />
<input type="submit" name="submit" id="submit" value="Submit" />
</form>
</body>
</html>
File Upload Handler
/upload.php
:
<?php
$tempFile = $_FILES['myfile']['tmp_name'];
$fileName = $_FILES['myfile']['name'];
$fileDestination = __DIR__."/uploads/".$fileName;
copy($tempFile, $fileDestination);
unlink($tempFile);
Note :
An /uploads
folder must be created beforehand.
💖 💪 🙅 🚩
Mohamed Hammi
Posted on November 19, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.