php - $_FILES 不工作并且没有给出错误

标签 php linux apache forms http-post

这是我的 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 表单中。我在互联网上搜索了每个网站,但找不到问题。

最佳答案

你有错误的属性:

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

应该是name:

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

这就是为什么 $_FILES 是空的;将属性 mame 固定为 name 后,它将起作用。

关于php - $_FILES 不工作并且没有给出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19779564/

相关文章:

linux - 将 HTTP 重定向到 HTTPS。最好的方法是什么?

java - Tomcat窗口启动后会自动关闭

angularjs - 错误 403 - 带有 Angular 项目的 XAMPP

javascript - 单击 div 时在弹出窗口中打开 YouTube 链接

php - 如何将每个 php foreach 值放入每个 jquery ajax

linux - 通过将 -lrt 传递给 gcc 修复了对 `timer_getoverrun' 的 undefined reference 。但为什么?

linux - 发送最近的文件附件

PHP:文本 explode ()问题

javascript - 404 错误 : localhost MAMP server cannot find javascript file

Python(还有 C)由 gethostbyname 完成的奇怪排序