2017-03-16 101 views
0

我是嘗試下載上傳file.upload做成功,但我不能下載這個文件,在這裏我的腳本CakePHP的1.3文件下載

控制器: 功能下載($ ID){$ 這 - > 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

最後解決了這個問題

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); 
}