So I was making an HTML, PHP and ZIP file submission.
I expect to upload the file to the directory and showing file info and contents from if
. But when I upload an HTML file, the File info shows blank, and it keeps showing contents from else
.
Here is the complete code:
HTML
<html>
<head>
<title>Submit HTML, PHP File</title>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<h1>Submit a File to HTMLtest [BETA]</h1>
<h3>only HTML, PHP, and ZIP files containing files for making a website are allowed.</h3>
<form action="/HTMLtest/submit-file/submitted.php" method="post">
<input type="file" name="FileUpload">
<br>
<input type="submit" value="Submit">
</form>
</body>
</html>
PHP
<html>
<head>
<title>Upload File</title>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<h1>File Info</h1>
<?php
echo "<b>File Name: </b><p>". $_FILES['FileUpload']['name'] . "</p><br>";
echo "<b>File Type: </b><p>". $_FILES['FileUpload']['type'] . "</p><br>";
echo "<b>File Location: </b>". $_FILES['FileUpload']['tmp_name']. "</p><br>";
echo "<b>File Size: </b><p>". $_FILES['FileUpload']['size'];
echo " B";
echo "</p><br><br>";
$FileSource = $_FILES['FileUpload']['tmp_name'];
$FileUpload = '/HTMLtest/submit-file/pending/'. $_FILES['FileUpload']['name'];
if (($_FILES['FileUpload']['type'] == "text/html") or ($_FILES['FileUpload']['type'] == "text/php") or ($_FILES['FileUpload']['type'] == "application/zip"))
{
copy($FileSource,$FileUpload);
echo "<h1>Upload Complete!</h1>";
echo "<h3>Your file is submitted and it's currently pending approval</h3>";
}
else
{
echo "<h3>Sorry, you can only upload HTML, PHP and ZIP files. ZIP files must contain HTML and PHP files.</h3>";
}
?>
<br><br>
<a href="/HTMLtest/submit-file/">Upload another file</a>
</body>
</html>
How could I fix this?