Tuesday 11 June 2013

Restricting File upload box type

<!-- Match all image files (image/*) -->
<input type="file" accept="image/*">

<!-- Match all video files (video/*) -->
<input type="file" accept="video/*">

<!-- Match all audio files (audio/*) -->
<input type="file" accept="audio/*">

<!-- Match all image files (image/*) and files with the extension ".someext" -->
<input type="file" accept=".someext,image/*">
<!-- See note below -->

<!-- Match all image files (image/*) and video files (video/*) -->
<input type="file" accept="image/*,video/*">
<!-- See note below -->


The accept attribute may be specified to provide user agents with a hint of what file types will be accepted.
If specified, the attribute must consist of a set of comma-separated tokens, each of which must be anASCII case-insensitive match for one of the following:

The string audio/*

  • Indicates that sound files are accepted.

The string video/*

  • Indicates that video files are accepted.

The string image/*

  • Indicates that image files are accepted.

valid MIME type with no parameters

  • Indicates that files of the specified type are accepted.

A string whose first character is a U+002E FULL STOP character (.)

  • Indicates that files with the specified file extension are accepted.

No comments:

Post a Comment