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

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

问题描述

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

 < form enctype =multipart / form-dataaction =uploader.phpmethod =POST> 
Upload DRP File:
< input name =Upload Saved Replaytype =fileaccept =*。drp/>< br />
< input type =submitvalue =Upload File/>
< / form>

编辑
我知道验证可以使用javascript,我希望用户只能在弹出的对话框中看到.drp文件。另外,我对这个应用程序中的服务器端验证并不在意。 对于像你这样的特定格式, 。你可以直接在accept =。drp中传递它,它可以工作。


但没有*


    


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>

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.

解决方案

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

But without " * "

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

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

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