Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filter Extensions in HTML form upload [duplicate]

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.

like image 394
ripper234 Avatar asked Oct 31 '08 16:10

ripper234


People also ask

How do I restrict multiple file uploads in HTML?

To allow multiple file uploads in HTML forms, use the multiple attributes. The multiple attributes work with email and file input types. For limiting maximum items on multiple inputs, use JavaScript. Through this, limit the number of files to be uploaded.

How do I restrict the file upload in react?

You can restrict the minimum allowed file size (in bytes) by using the minFileSize property. If the selected file is less than the minimum size, an error message will be displayed.


1 Answers

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/>
like image 152
ParaMeterz Avatar answered Sep 29 '22 21:09

ParaMeterz