YahyaE
YahyaE

Reputation: 1057

Codeigniter get_file_info() returns filename as false

I am building a Codeigniter based File Browser but having a problem with file information.

I have loaded helpers:

$this->load->helper('file');
$this->load->helper('directory');

When I called var_dump(get_file_info('gui/default/uploads/profile_200x200.jpg')); here is the result: (note that path is relative to site_url())

array (size=4)
  'name' => boolean false
  'server_path' => string 'gui/default/uploads/subfold/profile_200x200.jpg' (length=47)
  'size' => int 9714
  'date' => int 1386054354

But when I called get_filenames() or get_dir_file_info() from very same built-in file helper it displays filenames correctly. Any experience or idea what causes this?

Upvotes: 0

Views: 2724

Answers (1)

num8er
num8er

Reputation: 19372

due to bug with this function (read from here) use this workaround:

$file = 'gui/default/uploads/profile_200x200.jpg';
$fileinfo = get_file_info($file);
if(!$fileinfo['name']) $fileinfo['name'] = basename($file);

Upvotes: 1

Related Questions