0
아약스없이 cakephp 이미지 업로드가 정상적으로 작동합니다. 아약스 사용 후 데이터는 이미지 디렉토리없이 삽입됩니다. 여기 cakephp-2.4 : jshelper 아약스 제출 후 이미지 디렉토리 전송 안 함
은 JS 제출 버튼<?php echo $this->Js->submit('Submit',array(
'before'=>$this->Js->get('#sending')->effect('fadeIn',array('speed' => 'slow')),
'success'=>$this->Js->get('#sending')->effect('fadeOut',array('speed' => 'slow')),
'class' => 'btn btn-danger',
'style'=>'width:45%;margin-top:1%;height:30px;')
);
?>
보기 파일 필드 여기
echo $this->Form->input('product_image',array('type' => 'file','label' => false,));
내 모델 여기에 코드
public function processCoverUpload($check = array()) {
if (!is_uploaded_file($check['product_image']['tmp_name'])) {
return FALSE;
}
if (!move_uploaded_file($check['product_image']['tmp_name'], WWW_ROOT . 'img' . DS . 'uploads' . DS . $check['product_image']['name'])) {
return FALSE;
}
$this->data[$this->alias]['product_image'] = 'uploads/'. $check['product_image']['name'];
return TRUE;
}
컨트롤러 여기
if ($this->request->is('post')) {
$this->MadProduct->create();
$data = $this->request->data['MadProduct'];
if (!$data['product_image']['name']) {
unset($data['product_image']);
}
if ($this->MadProduct->save($data)) {
$this->Session->setFlash(__('The mad product has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The mad product could not be saved. Please, try again.'));
}
}
임
이미지 디렉토리를 jshelper로 보내려면 어떻게해야합니까?