English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML reference manual

HTML tag大全

HTML: <input> accept attribute

The accept attribute specifies the filter for the file types that users can select from the file input dialog (only for type ="file"), note: the accept attribute can only be used with <input type ="file">

 HTML <input> etiqueta

Online example

Specify the file types that users can select from the file input dialog:

!DOCTYPE html
<html>
<head>
<title>HTML: <input> accept attribute - Basic Tutorial Network (oldtoolbag.com)</title>
<body>
<form action="action_page.php">
  <input type="file" name="pic" accept="image/*">
  <input type="submit">
</form>
</body>
</html>
Test and see ‹/›

Browser compatibility

IEFirefoxOperaChromeSafari

Internet Explorer 10, Firefox, Opera, Chrome and Safari 6 Supports the accept attribute.

Note:Internet Explorer 9 Previous versions did not support the accept attribute of the <input> tag.

Define y uso

La propiedad accept especifica el filtro de tipos de archivo que los usuarios pueden seleccionar en el cuadro de diálogo de entrada de archivos (solo para type ="file").
Nota: La propiedad accept solo se puede usar con <input type ="file">.

Consejo: No utilice esta propiedad como herramienta de validación. La carga de archivos debe validarse en el servidor para asegurar la seguridad de la carga.

HTML 4.01 con HTML5las diferencias

Ninguna.

Sintaxis

<input accept="audio/*|video/*|image/*|Tipo_MIME">

Consejo:Si se deben especificar varios valores, utilice comas para separarlos (por ejemplo <input accept="audio/*,video/*,image/*" /)。

Valor del atributo

ValorDescripción
audio/*Acepta todos los archivos de sonido.
video/*Acepta todos los archivos de video.
image/*Acepta todos los archivos de imagen.
Tipo_MIMEUn tipo MIME válido, sin parámetros. Vea IANA Tipo MIME,以获得标准 MIME 类型的完整列表。
 HTML <input> etiqueta