안녕하세요 저는 파일을 업로드 할 수있는 파일 업로드 시스템을 만들려고하고 파일 이름을 테이블에 업로드 된 MYSQL ID로 변경합니다. 파일이 디렉토리에 업로드되는 것이 아니라, 정보가 SQL의 타베에 업로드되고 그러나 이 ...CakePHP 2.0 파일 업로드가 작동하지 않습니다.
function add() {
if (!empty($this->data)) {
$this->Upload->create();
if ($this->uploadFile() && $this->Upload->save($this->data)) {
$this->Session->setFlash(__('<p class="uploadflash">The upload has been saved</p>', true));
$this->redirect(array('action' => 'add'));
} else {
$this->Session->setFlash(__('<p class="uploadflash">The upload could not be saved. Please, try again.</p>', true));
}
}
}
function uploadFile() {
$file = $this->request->data['Upload']['file'];
if ($file['error'] === UPLOAD_ERR_OK) {
if (move_uploaded_file($file['tmp_name'], APP.'webroot/files/uploads'.DS.$this->Upload->id.'.mp4')) {
$this->Upload->save($this->data);
return true;
}
}
return false;
}
내 코드입니다.
이 기능 $ this-> Upload-> id가 파일 이름 바꾸기를 위해 작동하지 않는 이유가 표시되지 않습니까? 내가 스피치 마크에 넣으면 파일 이름을 "$ this-> Upload-> id.mp4"로 바꿉니다.하지만 정보가 저장되는 필드가 114.mp4와 같을 때가길 원합니다. 아무도 아이디어가 있습니까?
미리 감사드립니다.
당신에게 그것을 일이 대단히 감사합니다 처음에는 이름을 바꾸고 이름을 바꾸는 경우에 불과했습니다. 매우 감사! – 001221