Filter Extensions in HTML form upload

ripper234 picture ripper234 · Oct 31, 2008 · Viewed 109.5k times · Source

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.

Answer

ParaMeterz picture ParaMeterz · Jun 11, 2013

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/>