我想在我的网站上使用codeigniter的上传库添加文件上传功能。codeigniter do_upload不工作
这里是我的视图文件(Display.php的):
<html>
<body>
<form method="post" action="" enctype="multipart/form-data">
<input type="file" name="filename" />
<input type="submit" name="submit" id="submit" value="submit"/>
</form>
</body>
</html>
和这里的控制器:
public function testupload()
{
if (! empty($_FILES))
{
echo 'start upload';
$config['upload_path'] = './assets/img/tempfile/';
$this->load->library('upload');
$this->upload->initialize($config);
if (! $this->upload->do_upload('filename'))
{
echo 'error!';
}
else
{
echo 'success!';
}
echo 'end upload';
}
$this->load->view('display', $this->data);
}
但代码看起来$this->upload->initialize($config);
之后停止该文件没有上传,并有根本没有消息。只有'start upload'
消息出现;不出现echo 'success'
,echo 'error'
和echo 'end upload'
。
这是为什么?谁能帮我??
使用'$ this-> upload-> display_errors()'调试错误 –
启用调试模式。 'ini_set('display_errors','1'); error_reporting(E_ALL);'并打印这个以及'$ this-> upload-> display_errors()'; – Naga
nope。没有任何工作。如果放在'$ this-> upload-> do_upload('文件名')之后,甚至没有简单的'echo'blabla';';我尝试了@Naga的建议,但仍然没有任何结果。 – dapidmini