我尝试下载已成功完成上传的file.upload但我无法下载此文件,此处为我的脚本
控制器: 功能下载($ id){ $ this-> view =' Media';
$name = trim($id, '.gsm');
$params = array(
'id' => $id,
'name' => $name,
'download' => true,
'extension' => 'gsm',
'mimeType' => array('gsm' => 'audio/gsm'),
'path' => WWW_ROOT.'files'.DS.'vr'.DS,
);
print_r($params);
$this->set($params);
}
查看:
<?php echo $this->Html->link('Download', array('controller' => 'AudioDownloads', 'action' => 'download', $cdrCus['CdrCus']['uniqueid'].'.gsm')); ?>
显示错误
download/1489637104.427.gsm' was not found on this server.
我该如何解决?任何人都可以帮助我吗?
答案 0 :(得分:0)
最终解决了这个问题
function download($id=NULL) {
$this->view = 'Media';
$gid = trim($id);
$data = explode(".gsm", $gid);
$names = $data[0];
$params = array(
'id' => $gid,
'name' => $names,
'extension' => 'gsm',
'mimeType' => array(
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'gsm' => 'audio/gsm'
),
'path' => WWW_ROOT . 'files' . DS . 'vr' . DS,
);
$this->set($params);
}