<body>
<div class="wrapper">
<div class="header">
<h1>Text2<span class="fancy">FairyTale</span></h1>
<h4>Input: text, Output: <span class="fancy">fairy tale</span></h4>
</div>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
echo "<pre>";
print_r($_FILES);
echo "</pre>";
$filename = $_FILES["file-input"]["name"];
$extension = pathinfo($filename, PATHINFO_EXTENSION);
move_uploaded_file($_FILES["file-input"]["tmp_name"], $filename);
}
?>
<div class="upload-form">
<form action="" method="post" encytype="multipart/form-data">
<div class="upload">
<input type="file" name="file-input" class="file-input">
<input type="button" value="Browse">
<span class="filename">No file selected</span>
</div>
<input type="submit" name="submit" value="Upload">
<span class="valid-formats">Valid input: .txt files <= 512 KB</span>
</form>
</div>
</div>
</body>
答案 0 :(得分:4)
你只写表单属性错误不是 encytype 是 enctype
enctype="multipart/form-data"