推荐关注
› Meteor
› JSLint - a JavaScript code quality tool
› jsFiddle
› D3.js
› WebStorm
推荐书目
› JavaScript 权威指南第 5 版
› Closure: The Definitive Guide
az09py

accept=".txt"或者"text/plain"都包含些其他文本格式,而不只是.txt

  •  
  •   az09py · Dec 4, 2018 · 4181 views
    This topic created in 2891 days ago, the information mentioned may be changed or developed.

    要想上传文件格式限制为 txt,只能通过 File.name 来判断么

    Supplement 1  ·  Dec 4, 2018
    其他文本格式比如 .csv .js .py ,没有被 accept=".txt"或者"text/plain"限制,也能选中上传
    3 replies  •  2018-12-04 19:33:46 +08:00
    dobelee
    dobelee
    Dec 4, 2018 via Android
    1
    其他文本格式是什么鬼?
    maichael
    maichael
    Dec 4, 2018
    2
    accept 只是配置了系统打开文件的默认格式,不表示就不能选其他类型的文件。

    要限制文件类型,你只能在用户选择了文件之后,通过判断文件的类型来报错。
    ysc3839
    ysc3839
    Dec 4, 2018
    3
    意思是你只在前端设置了 accept=".txt"?还得在后端校验的。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2994 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 12:06 · PVG 20:06 · LAX 04:06 · JFK 07:06
    ♥ Do have faith in what you're doing.