1

这是我的 html 页面,其中包括表单:

<html>
    <head>
        <meta charset="UTF-8"/>
    </head>
    <body style="text-align:center;" >
        <form id="upload" action="file_upload.php" method="post" enctype="multipart/form-data">
            <input type="hidden" name="MAX_FILE_SIZE" value="12412412" /> 
            <label for="file">Dosya Adı:</label>
            <input type="file" mame="file" id="file"/>
            <br/>
            <input type="submit" name="submit" value="Yükle"/>
        </form>
    </body>
</html>

这是我的 file_upload.php 文件:

<pre>
    <?php print_r($_FILES); ?>
</pre>

<?php
    if( $_FILES["file"]["error"] > 0 ){
        echo 'Error : ' . $_FILES["file"]["error"]. '<br/>';
    }
    else {
        echo "File : " . $_FILES["file"]["name"] . "<br/>";
        echo 'File Type : ' . $_FILES["file"]["type"] . '<br/>';
        echo 'File temp adr: : ' . $_FILES["file"]["tmp_name"] . '<br/>';
    }
?>

我的 php 信息记录:

file uploads : on
max file uploads : 20
upload max file size : 32M
post max size : 32M

并且我的 tmp 文件夹权限设置为 777。我正在使用 bitnami mamp stack 5.4.9 上的 mac os 10.9

file_upload.php 给了我这个:

Array
(
)

File :
File Type :
File temp adr: : 

我尝试<input type="hidden" name="MAX_FILE_SIZE" value="12412412" /> 在我的 html 表单中使用和不使用。我在互联网上搜索了每个站点,但找不到问题。

4

1 回答 1

4

你有错误的属性:

<input type="file" mame="file" id="file"/>

它应该是name

<input type="file" name="file" id="file"/>

这就是为什么$_FILES是空的;修复属性mamename它会起作用。

于 2013-11-04T23:58:05.917 回答