我正在开发 Cakephp 2.x .. 我现在所做的是 .. 我正在向用户显示一个表单,在该表单中我给了他上传音频文件的选项 .. 所以我从用户 .. 我将文件保存到 app/uploads 文件夹中 .. 并将路径保存到数据库中...现在的问题是我不知道如何检索我的音频文件并将它们显示到我的视图页面中
这是我的上传功能
public function audio(){
if ($this->request->isPost()){
$this->loadModel('Audio');
$file = $this->request->data['Audio']['file'];
$idUser = $this->Auth->user('idUser');
if ($file['error'] === UPLOAD_ERR_OK) {
$id = String::uuid();
$name =$file['name'];
$folder_url = APP.'uploads/'.$idUser;
if(!is_dir($folder_url)) {
mkdir($folder_url);
}
move_uploaded_file($file['tmp_name'], $folder_url.DS.$name);
$this->request->data['Audio']['User_id'] = $idUser;
$this->request->data['Audio']['filename'] = $file['name'];
$this->request->data['Audio']['filesize'] = $file['size'];
$this->request->data['Audio']['filemime'] = $file['type'];
$this->Audio->save($this->request->data);
return true;
}
}
return false;
}
public function showAllAudioFiles(){
}
现在特定用户的文件已存储到此文件夹app/uploads/23/file.mp3