<?php if ($this->request->is('post')) { $data = $this->request->data; pr($data); $multi = implode(",",$data['Form']['mcheckbox']); $data['Form']['mcheckbox']= $multi; if(!empty($data)) { $image = $this->data['Form']['image']; pr($image); $imageTypes = array("image/gif", "image/jpeg", "image/png", "image/jpg"); pr($imageTypes); $uploadFolder = "image"; echo $uploadPath = WWW_ROOT . $uploadFolder; foreach ($imageTypes as $type) { pr($type); if ($type == $image['type']) { if ($image['error'] == 0) { $imageName = $image['name']; if (file_exists($uploadPath . '/' . $imageName)) { $imageName = date('His') . $imageName; } $full_image_path = $uploadPath . '/' . $imageName; if (move_uploaded_file($image['tmp_name'], $full_image_path)) { $this->Session->setFlash('File saved successfully'); $this->set('imageName',$imageName); } else { $this->Session->setFlash('There was a problem uploading file. Please try again.'); } } else { $this->Session->setFlash('Error uploading file.'); } break; } else { $this->Session->setFlash('Unacceptable file type'); } } } $mod = $this->Form->adddata($data); if($mod) { $this->Session->setFlash(__('Your post has been saved.')); } else { $this->Session->setFlash(__('Unable to add your post.')); } } } ?>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)