<?php
if(isset($_POST['submit'])){
$file = $_FILES['file'];
$name = $file['name'];
$type = $file['type'];
$tmp_name = $file['tmp_name'];
$error = $file['error'];
$extension = explode('.', $name);
$extension = end($extension);
$extension = strtolower($extension);
$allowed = ['txt', 'php', 'html'];
$directory = 'assignment/';
if(in_array($extension, $allowed)){
$location = $directory . $name;
move_uploaded_file($tmp_name, $location);
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form method="post" enctype="multipart/form-data">
<input type="file" name="file" id="">
<input type="submit" name="submit" id="">
</form>
</body>
</html>
if(isset($_POST['submit'])){
$file = $_FILES['file'];
$name = $file['name'];
$type = $file['type'];
$tmp_name = $file['tmp_name'];
$error = $file['error'];
$extension = explode('.', $name);
$extension = end($extension);
$extension = strtolower($extension);
$allowed = ['txt', 'php', 'html'];
$directory = 'assignment/';
if(in_array($extension, $allowed)){
$location = $directory . $name;
move_uploaded_file($tmp_name, $location);
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form method="post" enctype="multipart/form-data">
<input type="file" name="file" id="">
<input type="submit" name="submit" id="">
</form>
</body>
</html>
No comments:
Post a Comment