这是我第一次在构建我的学校项目时使用codeigniter。Codeigniter发布不起作用
让我直行吧。
我可以得到我的POST请求,除了form_upload();
这是我的样表:
<?php
echo form_open('admin/test_upload');
echo form_input(array('name' => 'title'));?><br/><?
echo form_upload(array('name' => 'file'));
echo form_submit(array('name' => 'submit', 'value' => 'submit'));
echo form_close();
?>
这是我的控制器:
function test_upload(){
$data['header'] = "TEST UPLOAD";
var_dump($_POST) ; //basically, this is function echoes back the post array.
$this->load->view('admin/dashboard_view', $data);
}
这是输出
array(2) {
["title"]=>
string(3) "asd"
["submit"]=>
string(6) "submit"
}
//The ["file"] is missing.... wHAT!?>
有人能帮助我吗?
好,那我该如何检索这个请求?我可以使用$ this-> input-> post('file'); ? – 2012-08-14 14:03:50
您将使用'$ _FILES ['file'] ['tmp_name']'获取临时上传文件的路径,然后您可以将其复制到服务器或执行任何操作。 '$ _FILES ['file'] ['name']'将包含上传文件的原始路径。 [PHP.net上的文档]中有更详细的信息(http://www.php.net/manual/en/features.file-upload.post-method.php)。 – Quantastical 2012-08-14 14:41:54