예를 들어 foo.png 파일을 업로드하는 경우 업로드 컨트롤러에서 "foo.png"문자열을 가져 오는 방법은 무엇입니까?Codeignator 업로드 컨트롤러에서 이미지 이름을 얻으려면 어떻게해야합니까?
컨트롤러 코드는 다음과 같습니다
<?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
을 설정할 수 있습니까?