Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7644489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:42:04+00:00 2026-05-31T09:42:04+00:00

Hi! I use Cake 2.1 , and I would like to know what is

  • 0

Hi!

I use Cake 2.1, and I would like to know what is the right way to deliver myself the classes that I build in order to use them wherever I want (in a Model, Controller class).

I know that there is the component for using in the context of a Controller, but what about the contxt of a Model ?

A particular case when I might need this is when creating a class that deals with moving uploaded files to predefined paths, depending of the model, or file type. I want to use it in the beforeSave() method of the model and then, finally, to save the path in a fied of the table on which the model is mapped…

The easiest way for me would be to use the bootstrap.php in order to load all I need, but I guess that is not exactly right, especially when there is a considerable number of classes..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:42:06+00:00Added an answer on May 31, 2026 at 9:42 am

    If you have a generic piece of code that is thought to be shared between models its called a behavior. See http://book.cakephp.org/2.0/en/models/behaviors.html

    Validation of the file upload should be done in a model too. We’ve wrote a FileUploadBehavior for that, that deals with file uploads and its possible errors but I can’t share this code. We might open source it.

    And by the way, for storing files I can suggest you this nice library https://github.com/avalanche123/Imagine I’ve already used it and it works really good.

    In the case of Imagine you would place the lib inside app/Vendor/Imagine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to use the URL address as filename instead of i. Thought
I have a contact form that doesn't use a model. What's the best way
I am moving my website to use cake php and before i would just
I would like to extend the cakephp logging facility. Using $this->log($msg, $level) you can
I have an edit form where I would like to update a number of
I have a class Called MyClass. It lives in app/Lib/MyDir/MyClass. I'd like to use
Summary of the question: I would like to create a CakePHP based registration and
This is my first time trying to use cake and i think im starting
While certain guidelines state that you should use an interface when you want to
I would like to store a period of time (20 minutes, 3 hours, 76

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.