0

I have a problem here and I wish you could help me. So, I have a controller x_controller.php, with its model.

I have some simple text inputs and selects, but also some file inputs, plus there's a button[Add 1 more file] which generates another file type input. How would I upload each of these file inputs in another table, like myFiles?

And each file should be a new row in myFiles.

Stecya
  • 22,896
  • 10
  • 72
  • 102
Sergiu
  • 199
  • 1
  • 11

2 Answers2

0

You will need to add the other model to your x_controller using the $uses like this:

var $uses = array('ThisModel','SomeOtherModel');

To save to the other mdoel use:

$this->SomeOtherModel->save($someOtherModel);
cowls
  • 24,013
  • 8
  • 48
  • 78
  • $uses is not considered very good practise. You should load another model only when needed. Look this answer: http://stackoverflow.com/a/4753244/829198 – Henri Dec 10 '11 at 17:58
0
loadModel('MyFile');
$myFile = new MyFile();
//write your code to upload file, then add to database
$myFile->save($saveYourUploadedFilePath);

Sudhir Bastakoti
  • 99,167
  • 15
  • 158
  • 162