看板 PHP 關於我們 聯絡資訊
各位大大好︰ 小弟想把檔案傳給手機應用, 但不想把檔案地址發給他, 於是做了一些麻煩的事情....... public function downloadFileByFileToken_post() { $fileToken = $this->input->post('FileToken'); $this->load->model('system_model'); $filePath = $this->system_model->getFilePathByFileToken($fileToken); if (file_exists($filePath)) { $path_parts = pathinfo($filePath); $this->load->model('system_model'); $newFileName = $this->system_model->generateRandomString(16); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.$newFileName.'.'.$path_parts['extension']); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: '.filesize($filePath)); readfile($filePath); exit; } else { echo 'ERROR'; } } 我用的是codeigniter, 回傳到ie是一個檔案的下載, 但是幫我做android的朋友說他沒法 接, 是他該改還是我改呢? 我有方法header可以直傳檔案麻?? 還是我的思路都錯了? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 183.178.187.30 ※ 文章網址: https://www.ptt.cc/bbs/PHP/M.1435632564.A.C07.html
KawasumiMai: 如果回傳到IE是一個檔案下載,那Android的做法是否 06/30 11:40
KawasumiMai: 是呼叫瀏覽器連結這個網址呢? 06/30 11:40
cnyug: 對呀,我就是不懂,他說不行,是不是我做錯了?那我該怎麼做呢? 07/01 10:12
Jerr: 有走https嗎? 07/01 11:45