• 请不要在回答技术问题时复制粘贴 AI 生成的内容
hello321
V2EX  ›  程序员

为啥 wps 生成的 docx 的 mime 不是 word 文档

  •  
  •   hello321 · Dec 9, 2020 · 2290 views
    This topic created in 2162 days ago, the information mentioned may be changed or developed.

    laravel 项目的上传文件类型限制有了问题,识别不出 wps 的 docx. ps .v2 规则头痛,描述了一堆,提示我要注册 1000 天才能发布.

    hello321
    hello321
    OP
    Dec 9, 2020
    1
    office 的 docx xlsx 可以被正确识别文件类型
    wps 的 docx xlsx 不可以被识别
    wps 的 doc 也是可以被正确识别的
    mitoop
    mitoop
    Dec 9, 2020
    2
    是的 之前遇到 wps docx 识别错误 通过后台判断 client mime type 是否是 `application/vnd.openxmlformats-officedocument.wordprocessingml.documen` 特殊处理了
    zjsxwc
    zjsxwc
    Dec 9, 2020
    3
    和你的浏览器有关吧,判断文件 mime type 只是匹配文件前几个字节而已,我之前把 chrome c++代码改成 php

    https://github.com/zjsxwc/mime-type-sniffer
    hello321
    hello321
    OP
    Dec 9, 2020
    4
    @zjsxwc 大佬这个妙
    hello321
    hello321
    OP
    Dec 9, 2020
    5
    @mitoop 👍👍👍
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1224 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 23:38 · PVG 07:38 · LAX 15:38 · JFK 18:38
    ♥ Do have faith in what you're doing.