无法获得$ _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个回答

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>
dt614037527
dt614037527 .. :) 好人! 我没有真正注意到它..所有修复! :)
7 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐