php實現上傳Excle檔案

來源:互聯網
上載者:User
PHP Excel

要實現php上傳EXCEL時,在選擇檔案時,只顯示EXCEL檔案,還有就是如何判斷$upfile=$_FILES["upfile"];$type = $upfile["type"]; $type是excel的, 我試過$type=="xls"不行,它應該等於什麼,還有一個問題就是上傳時,不是都是先把檔案上傳到一個臨時檔案,然後在移動到指定目標,這個臨時檔案怎麼刪除


回複討論(解決方案)

1、$upfile["type"]:

xla application/vnd.ms-excel
xlc application/vnd.ms-excel
xll application/x-excel
xlm application/vnd.ms-excel
xls application/vnd.ms-excel
xlt application/vnd.ms-excel
xlw application/vnd.ms-excel

2、臨時目錄不用你管,上傳程式執行完系統會自動刪除臨時檔案。

1、$upfile["type"]:

xla application/vnd.ms-excel
xlc application/vnd.ms-excel
xll application/x-excel
xlm application/vnd.ms-excel
xls application/vnd.ms-excel
xlt application/vnd.ms-excel
xlw application/vnd.ms-excel

2、臨時目錄不用你管,上傳程式執行完系統會自動刪除臨時檔案。
這些都是excle格式的嗎,只要$type="application/vnd.ms-excel"這樣嗎

我是寫個這個?
witch ($type) {
case 'xla application/vnd.ms-excel ' : $ok=1;
break;
case 'xlc application/vnd.ms-excel' : $ok=1;
break;
case 'xll application/x-excel ' : $ok=1;
break;
case ' xlm application/vnd.ms-exce' : $ok=1;
break;
case 'xls application/vnd.ms-excel' : $ok=1;
break;
case 'xlt application/vnd.ms-excel' : $ok=1;
break;
case 'xlw application/vnd.ms-excel' : $ok=1;
break;

}

判斷副檔名吧

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.