For uploading multiple files first we have to download multipartfile master plugin file from http://www.fyneworks.com/jquery/multifile/ then we have to include its file into our code as shown below.
<script src="path/to/your/jquery.MultiFile.js" type="text/javascript" language="javascript"></script>
Then we have to put following code into our view document.
<?php echo $this->Form->input('pic.',array('label'=>'','class'=>'multi with-preview','type'=>'file'));?>
Below is the logic for our controller.
public function registration(){
if (isset($this->data["Image"]["pic"]) && $this->data["Image"]["pic"] != "") {
foreach($this->data["Image"]["pic"] as $key){
$imgData['file'] = $key;
$imgData['name'] = $key['name'];
$imgData['path'] = WWW_ROOT . '' . 'imag/';// path where the image will we copied
$user_image = $this->Qimage->copy($imgData);//Qimage copy function
// Qimage resizing function,
$this->Qimage->resize(
array(
'height' => 80,
'width' => 80,
'file' => $imgData['path'].$user_image,
'output' => WWW_ROOT. 'imag/thumbnail/' // path where the image will we uploaded after resizing
)
);
$imgRec['Image']['pic']= $user_image;
$imgRec['Image']['username']=$user['username'];
$this->User->create();
$this->Licence->save($imgRec);
}
}
else{
$user_image = "";
}
}
0 Comment(s)