close
最近用Kohana寫檔案上傳的程式,遇到一個奇怪的現象,就是只有docx、xlsx不能上傳,但是如果將檔案存成doc就可以上傳了,這時候還笨笨的沒想到原因,突然閃到一個mime的設定檔,馬上就猜是不是沒有定義。開啟了設定檔檢查了一下,果然沒有定義docx、xlsx等的mime
嗯…一開始是想說使用PHP的fileinfo取得檔案的mime後,再補上就好了。結果踢到鐵板呀/__\,fileinfo意外的都發生錯誤,悶了…所以我就直接google「docx mimetype list」,最後在這篇文章找到了定義值,我把他列在下面,或許改天有人也會用的到,就copy去吧!!
$office2007 = array( //office 2007的檔案格式 'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'), 'xltx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.template'), 'potx' => array('application/vnd.openxmlformats-officedocument.presentationml.template'), 'ppsx' => array('application/vnd.openxmlformats-officedocument.presentationml.slideshow'), 'pptx' => array('application/vnd.openxmlformats-officedocument.presentationml.presentation'), 'sldx' => array('application/vnd.openxmlformats-officedocument.presentationml.slide'), 'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document'), 'dotx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.template'), 'xlam' => array('application/vnd.ms-excel.addin.macroEnabled.12'), 'xlsb' => array('application/vnd.ms-excel.sheet.binary.macroEnabled.12') );
/__\ 話說我已經從CI轉用Kohana了…有空再跟大家分享
全站熱搜
留言列表