本文介绍了在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>

EditI 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.

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

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

09-12 08:26