PHP Implementation upload excle file

Source: Internet
Author: User
Tags php excel
PHP Excel

To implement PHP upload Excel, when selecting a file, only show Excel file, and how to judge $upfile=$_files["Upfile"]; $type = $upfile ["type"]; $type is Excel, I tried $type== "xls" does not, it should be equal to what, there is a problem is uploading, not all the first upload files to a temporary file, and then move to the specified target, how to delete this temporary file


Reply to discussion (solution)

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, temporary directory without your tube, upload the program after the system will automatically delete temporary files.

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, temporary directory without your tube, upload the program after the system will automatically delete temporary files.
Are these all in excle format, as long as $type= "application/vnd.ms-excel"?

I'm writing this one?
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

}

Judge the extension.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.