例如,如果我上传文件 foo.png 如何在上传控制器中获取字符串“foo.png”?
控制器代码为:
<?php
class Upload extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
$this->load->database();
}
function do_upload($folder)
{
$config['upload_path'] = './userdata/'. $folder . '/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
echo $this->upload->display_errors();
}
else
{
$data = array('upload_data' => $this->upload->data());
echo "<p>File sucesfully uploaded</p>";
$filename = // How do I get the filename here
}
}
}
?>
如何设置$filename
上传文件的文件名?