0
Iは、コントローラは、基本的にサーバ上に画像をアップロードするアクション追加ビューからコントローラに変数を渡すための適切なMVCモデルは何ですか?
機能追加($ NUMBER_OF_IMAGES = 1)を有する有し{
$this->set('number_of_images', $number_of_images); if (!empty($this->data)) { $count = 1; foreach($this->data['Images'] as $entry){ $file_name = "file" . $count; if ($data_s = $this->Uploader->upload($file_name)) { $this->Image->saveAll($data_s); } $count++; } $this->Session->setFlash("Your image(s) has been saved"); $this->redirect(array('action'=>'index')); } }
マイ追加ビューは、基本的にユーザが選択できます1ファイルをアップロードしてアップロードする
<?php
echo $this->Form->create('Images', array('type' => 'file', 'url' => array('controller' => 'images', 'action' => 'add')));
$count = 1;
while($count <= $number_of_images){
// file name is file + image number
$file_name = 'file' . $count;
echo $this->Form->input($file_name, array('type' => 'file'));
// echo $this->Form->input("File " . $count, array('type' => 'file'));
$count++;
}
echo $this->Form->end('Upload');
echo $this->Html->link('Go Back To Main Page', '/images')
?>
1つ以上のファイルを選択できるようにすることができます。 たとえば、cakephp/images/add/3に行くと、3つのアップロード選択フォームが作成されます。ここでadd.ctp