FriendsOfCake / cakephp-upload

CakePHP: Handle file uploading sans ridiculous automagic
https://cakephp-upload.readthedocs.io/
MIT License
551 stars 255 forks source link

Please how i get filetype in filenamecallback? #411

Closed marquesferreira closed 8 years ago

marquesferreira commented 8 years ago

i saw jose diaz talking about -> $currentName to get image filetype (.jpg,.png), but i don't have access to this variable...

how i can do it please? Where is this variable? show me the magic?

 public function filename()
    {
        $processor = Hash::get($this->settings, 'nameCallback', null);
        if (is_callable($processor)) {
          return $processor($this->data, $this->settings);
        }
        debug($this->data['name']);
       return $this->data['name']= $this->filerename($this->data);
    }

 public function filerename($data) {
         return $this->data['name'] = "a_lot_of_work_to_rename".".jpg";
}
josegonzalez commented 8 years ago

You can use the finfo_file to retrieve that information from a file.