Well, you should change $student to $student_id. Not only will that
make it a lot easier to see, at a glance, what's going on 3 months
from now when you need to change something, but Cake expects it that
way. If you have a model named Student and your MyFile model has a
foreign key pointing to Student and the students table, it should be
named $student_id.

As for the flash, try $this->Session->setFlash(...)



On Sat, Apr 26, 2008 at 12:44 AM, damo <[EMAIL PROTECTED]> wrote:
>
>  thanks again b logica.
>
>  Have tried what you have suggested with no luck.  What I am passing is
>  just an integer.  I am passing this integer to the function so I know
>  which student the file is for.  I just had a thought that it might be
>  easier to just pass the variable in the controller rather than in the
>  form since it is already there, and isn't input by the user...
>  something like this:
>
>
>         function add($student = null) {
>
>         if (!empty($this->data) &&
>              is_uploaded_file($this->data['Myfile']['File']
>  ['tmp_name'])) {
>             $fileData = fread(fopen($this->data['Myfile']['File']
>  ['tmp_name'], "r"),
>                                      $this->data['Myfile']['File']
>  ['size']);
>
>
>             $this->data['Myfile']['name'] = $this->data['Myfile']
>  ['File']['name'];
>             $this->data['Myfile']['type'] = $this->data['Myfile']
>  ['File']['type'];
>             $this->data['Myfile']['size'] = $this->data['Myfile']
>  ['File']['size'];
>             $this->data['Myfile']['data'] = $fileData;
>             $this->data['Myfile']['student'] = $student;
>
>
>             $this->Myfile->save($this->data);
>
>             $this->flash('The file has been uploaded.', "/myfiles/view/
>  ${student}", 2);
>         }
>     }
>
>  The file saves to the database, but nothing is saved under the
>  'student' field..... also the 'flash' doesn't work correctly, and just
>  redirects to '/myfiles/view/'.
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to