为什么这个PHP没有工作?它说我的$ _FILES变量不存在,当我认为我已经创建它

时间:2013-02-02 18:57:35

标签: php html

<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 &lt;= 512 KB</span>
            </form>
        </div>
    </div>
</body>

1 个答案:

答案 0 :(得分:4)

你只写表单属性错误不是 encytype enctype

 enctype="multipart/form-data"