douyoufan7881 2013-01-24 16:19
浏览 38
已采纳

无法获得$ _FILES [重复]

Possible Duplicate:
Why files don’t get uploaded with this HTML/PHP?

i'm using Slim Framework to make a REST web service to do a simple service:

require 'Slim/Slim.php';

$app = new Slim();
$app->get('/update','showUpdatePage');
$app->post('/update','store');
$app->run();

function store(){
    print_r($_FILES);
}
function showUpdatePage(){
    echo <<<EOT
    <html>
        <body>
            <h2 style="text-align:center;">Load new file</h2>
            <div style="width:40%;margin:0 auto;">
                <form method="post" action="update">
                    <input type="file" name="theFile" enctype="multipart/form-data" />
                    <input type="submit" value="load"/>
                </form>
            </div>
        </body>
    </html>
EOT;
}

My problem is that the line

print_r($_FILES);

give me empty array.. how can i fix?

  • 写回答

1条回答 默认 最新

  • dongrao9454 2013-01-24 16:21
    关注

    enctype="multipart/form-data"

    This isn't an attribute of an input - it's a form attribute. As such your form is not setup to submit files, and the enctype attribute of the input will simply be ignored.

    Valid Example

    <form method="post" enctype="multipart/form-data" action="update">
        <input type="file" name="theFile">
        <input type="submit" value="load"/>
    </form>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法