Marques
Marques

Reputation: 399

The management of files and folders in codeIgniter can be made from controller or model?

I want to verify if file/folder exists on my CI system (not system folder), can i do it from controller or I need create a method on my model to do it?

Upvotes: 0

Views: 683

Answers (3)

Rana
Rana

Reputation: 6154

Best to add this function in a codeigniter helper or in a library class(if you are fan of OOP). Load this automatically with autoload.php and call from wherever you need it.

Upvotes: 0

SachinGutte
SachinGutte

Reputation: 7055

It's basically a matter of choice. You can define your function in both your model and controller. But if you want to use it over and over from different controllers, then better define a new model and put that function in it. I'd define model which is to be used by many controllers that is having some common-general methods. Just to keep things apart and maintaining them later. Helpers are also a way to keep things separate.

Upvotes: 1

Jeremie Ges
Jeremie Ges

Reputation: 2745

You have got many way for this :

  • You can create an helper and put your function like verify()
  • You can create a private function into your controller like

    private function _verify() { }
    

enjoy !

Upvotes: 0

Related Questions