V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
hello321
V2EX  ›  程序员

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

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

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

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

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