>         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']);

You're saving the file to the database, yes?

>  $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->set['Myfile']['student'] = $student;  ***** this line
>  stops it from saving, works fine without

You're using set() incorrectly. I's not an array, it's a method. And
the first param should be a string that will become the name of some
variable in your view.

First, is $student supposed to be an integer ID? You'd be better off doing:
$this->set('student_id', $student);
if only to make things more obvious.
>
>
>  $this->Myfile->save($this->data);
>
>  $this->flash('The file has been uploaded.', '/myfiles/view/'.$student,2);
>

Here you're passing $student to the route, so there's no need to set
the variable earlier. You probably only need one or the other. If you
choose to use set() then you could just do:

$this->Session->setFlash('The file has been uploaded.');
$this->render('view);

If you want to use the redirect instead, don't use set() and pass
$student as part of the path for the controller to pick up in that
action:

$this->flash('The file has been uploaded.', "/myfiles/view/${student}", 2);

--~--~---------~--~----~------------~-------~--~----~
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