I want to upload multiple pictures using this CakePHP-Plugin, which I use to attach uploads to the model: http://milesj.me/code/cakephp/uploader Unfortunately the documentation isn't very helpful on this. My plan is to submit the files one by one to circumvent the problems, which could arise if multiple bigger pictures are uploaded at once. What I need to do (at least I hope so) is to send a JSON-Request containing the local file-path and wait for the callback. How can I get the local filenames via javascript using an input field (with html5's muliple= multiple)? Another question would be, if there could be any problems, of which I haven't thought yet. I'm not sure how the callback-mechanic will work, as the data send is just a text and the upload itself handled by the plugin.
Edit: This is what I tried without using ajax. While this works in some occacions with multiple small files, it doesn't sometimes with multiple bigger images and also does not through back any errors.
public function add($album_id = null, $album_title = null) {
$this->set('album_id', $album_id);
$this->set('album_title', $album_title);
// debug($this->data);
if (!empty($this->request->data)) {
$data = $this->request->data;
$data['Picture']["album_id"]= $album_id;
foreach ($data['Picture']['files'] as $file){
$tmp_data = $data;
$tmp_data['Picture']['files']="";
$tmp_data['Picture']['file']=$file;
debug ($tmp_data);
$this->Picture->saveAll($tmp_data, array('deep' => true));
}
}
}