HTML 表单上传中的过滤器扩展 [英] Filter Extensions in HTML form upload

查看:29
本文介绍了HTML 表单上传中的过滤器扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的 HTML 上传表单,我想指定一个默认扩展名(例如*.drp").我读过这样做的方法是通过输入标签的 ACCEPT 属性,但我不知道具体是怎么做的.

I have a simple HTML upload form, and I want to specify a default extension ("*.drp" for example). I've read that the way to do this is through the ACCEPT attribute of the input tag, but I don't know how exactly.

<form enctype="multipart/form-data" action="uploader.php" method="POST">
Upload DRP File:
<input name="Upload Saved Replay" type="file" accept="*.drp"/><br />
<input type="submit" value="Upload File" />
</form>

编辑我知道可以使用 javascript 进行验证,但我希望用户只能在其弹出对话框中看到.drp"文件.另外,我不太关心这个应用程序中的服务器端验证.

Edit I know validation is possible using javascript, but I would like the user to only see ".drp" files in his popup dialog. Also, I don't care much about server-side validation in this application.

推荐答案

对于像你这样的特定格式.drp".你可以直接在 accept=".drp" 中传递它,它会起作用.

For specific formats like yours ".drp ". You can directly pass that in accept=".drp" it will work for that.

但是没有*"

<input name="Upload Saved Replay" type="file" accept=".drp" />
<br/>

这篇关于HTML 表单上传中的过滤器扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆