title: Pass variable from controller to model (beforeSave) (Upload Field) CakePHP
body: <p>I really need to know this issue to finish my work.</p>
  
  <p>Here I'll give a example envolving model and controller.
  I want to pass $final_name from controller to beforeSave() of my model</p>
  
  <pre><code>public function admin_add() {
      if($this-&gt;request-&gt;is('post')) {
          if($this-&gt;data['Client']['file']['tmp_name'] != '') {
                  // Upload block
                  $tmp_file = $this-&gt;data['Client']['file']['tmp_name'];
                  $file = new File($tmp_file);
                  if($file-&gt;mime() == "image/jpeg" or "image/png") {
                      $ext = explode('.', $this-&gt;data['Client']['file']['name']);
                      $name = md5($this-&gt;data['Client']['file']['name']);
                      $file-&gt;copy(IMG_DIR . 'portfolio\\' . $name . '.' . end($ext));
                      $final_name = $name . "." . end($ext); // File name with extension
                  }
                  // If save
              if($this-&gt;Client-&gt;save($this-&gt;request-&gt;data)) {
                  $this-&gt;Session-&gt;setFlash('Client cadastrado com sucesso!', 'admin_flash');
              }
          }
      }
  }
  </code></pre>
  
  <p>In my client model</p>
  
  <pre><code>public function beforeSave($options = array()) {
      if($this-&gt;data['Client']['file']['name'] != null) {
          $this-&gt;data['Client']['file'] = $final_name;
      }
      return parent::beforeSave($options);
  }
  </code></pre>