Fat models - skin controllers with File Uploading |
Hi all, I'd like to ask a question if possible regarding the "fat models - skin controllers" best practices.
I have inside my model a method that holds both file uploading and image manipulation. The code works ok, but the problem is I can't figure out how to get the upload error, if occured, back in the controller in order to pass it to the view and display it to the user, or the upload data if the uploading was done successfully. This is an example of the code in my model: PHP Code: class Foo_Model extends CI_Model The code inside the controller PHP Code: public function upload(){ Thanks in advance
do_upload should be in your controller not your model, models are for business logic like database access of records etc;
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(12-22-2014, 04:37 AM)InsiteFX Wrote: do_upload should be in your controller not your model, models are for business logic like database access of records etc; I'm not going to comment on the above code, because I use ajax for my uploading. But I have 6+ different "uploads" within my application. Do all 6 controllers have the logic to handle the uploading? Of course not, this would be silly to maintain 6 different code functions. Instead, I have 1 main upload "library" which each controller interfaces with and returns the data when an upload is successful or not. Ultimately, it's up to you what you decide to do. I never saw the logic in having models hold anything except database logic. Especially when you want to move away from CI. (12-23-2014, 01:15 AM)Lykos22 Wrote:not according to the definition accepted by CodeIgniter(12-22-2014, 04:37 AM)InsiteFX Wrote: models are for business logic like database access of records etc; Website: http://avenir.ro
|
Welcome Guest, Not a member yet? Register Sign In |