`

html上传文件

    博客分类:
  • html
阅读更多

在文件上传中使用 accept 属性,本例中的输入字段可以接受 GIF 和 JPEG 两种图像:

<form>
  <input type="file" name="pic" id="pic" accept="image/gif, image/jpeg" />
</form>

亲自试一试

如果不限制图像的格式,可以写为:accept="image/*"。

定义和用法

accept 属性只能与 <input type="file"> 配合使用。它规定能够通过文件上传进行提交的文件类型。

提示:请避免使用该属性。应该在服务器端验证文件上传。

语法

<input accept="value">

属性值

值 描述
MIME_type 用逗号隔开的 MIME 类型列表。

 

MIME 类型

MIME (Multipurpose Internet Mail Extensions) 是描述消息内容类型的因特网标准。

MIME 消息能包含文本、图像、音频、视频以及其他应用程序专用的数据。

官方的 MIME 信息是由 Internet Engineering Task Force (IETF) 在下面的文档中提供的:

  • RFC-822 Standard for ARPA Internet text messages
  • RFC-2045 MIME Part 1: Format of Internet Message Bodies
  • RFC-2046 MIME Part 2: Media Types
  • RFC-2047 MIME Part 3: Header Extensions for Non-ASCII Text
  • RFC-2048 MIME Part 4: Registration Procedures
  • RFC-2049 MIME Part 5: Conformance Criteria and Examples

不同的应用程序支持不同的 MIME 类型。

下面的参考手册是由 Microsoft Internet Information Server version 5 所支持的 MIME 类型列表。

按照内容类型排列的 Mime 类型列表

类型/子类型 扩展名
application/envoy evy
application/fractals fif
application/futuresplash spl
application/hta hta
application/internet-property-stream acx
application/mac-binhex40 hqx
application/msword doc
application/msword dot
application/octet-stream *
application/octet-stream bin
application/octet-stream class
application/octet-stream dms
application/octet-stream exe
application/octet-stream lha
application/octet-stream lzh
application/oda oda
application/olescript axs
application/pdf pdf
application/pics-rules prf
application/pkcs10 p10
application/pkix-crl crl
application/postscript ai
application/postscript eps
application/postscript ps
application/rtf rtf
application/set-payment-initiation setpay
application/set-registration-initiation setreg
application/vnd.ms-excel xla
application/vnd.ms-excel xlc
application/vnd.ms-excel xlm
application/vnd.ms-excel xls
application/vnd.ms-excel xlt
application/vnd.ms-excel xlw
application/vnd.ms-outlook msg
application/vnd.ms-pkicertstore sst
application/vnd.ms-pkiseccat cat
application/vnd.ms-pkistl stl
application/vnd.ms-powerpoint pot
application/vnd.ms-powerpoint pps
application/vnd.ms-powerpoint ppt
application/vnd.ms-project mpp
application/vnd.ms-works wcm
application/vnd.ms-works wdb
application/vnd.ms-works wks
application/vnd.ms-works wps
application/winhlp hlp
application/x-bcpio bcpio
application/x-cdf cdf
application/x-compress z
application/x-compressed tgz
application/x-cpio cpio
application/x-csh csh
application/x-director dcr
application/x-director dir
application/x-director dxr
application/x-dvi dvi
application/x-gtar gtar
application/x-gzip gz
application/x-hdf hdf
application/x-internet-signup ins
application/x-internet-signup isp
application/x-iphone iii
application/x-javascript js
application/x-latex latex
application/x-msaccess mdb
application/x-mscardfile crd
application/x-msclip clp
application/x-msdownload dll
application/x-msmediaview m13
application/x-msmediaview m14
application/x-msmediaview mvb
application/x-msmetafile wmf
application/x-msmoney mny
application/x-mspublisher pub
application/x-msschedule scd
application/x-msterminal trm
application/x-mswrite wri
application/x-netcdf cdf
application/x-netcdf nc
application/x-perfmon pma
application/x-perfmon pmc
application/x-perfmon pml
application/x-perfmon pmr
application/x-perfmon pmw
application/x-pkcs12 p12
application/x-pkcs12 pfx
application/x-pkcs7-certificates p7b
application/x-pkcs7-certificates spc
application/x-pkcs7-certreqresp p7r
application/x-pkcs7-mime p7c
application/x-pkcs7-mime p7m
application/x-pkcs7-signature p7s
application/x-sh sh
application/x-shar shar
application/x-shockwave-flash swf
application/x-stuffit sit
application/x-sv4cpio sv4cpio
application/x-sv4crc sv4crc
application/x-tar tar
application/x-tcl tcl
application/x-tex tex
application/x-texinfo texi
application/x-texinfo texinfo
application/x-troff roff
application/x-troff t
application/x-troff tr
application/x-troff-man man
application/x-troff-me me
application/x-troff-ms ms
application/x-ustar ustar
application/x-wais-source src
application/x-x509-ca-cert cer
application/x-x509-ca-cert crt
application/x-x509-ca-cert der
application/ynd.ms-pkipko pko
application/zip zip
audio/basic au
audio/basic snd
audio/mid mid
audio/mid rmi
audio/mpeg mp3
audio/x-aiff aif
audio/x-aiff aifc
audio/x-aiff aiff
audio/x-mpegurl m3u
audio/x-pn-realaudio ra
audio/x-pn-realaudio ram
audio/x-wav wav
image/bmp bmp
image/cis-cod cod
image/gif gif
image/ief ief
image/jpeg jpe
image/jpeg jpeg
image/jpeg jpg
image/pipeg jfif
image/svg+xml svg
image/tiff tif
image/tiff tiff
image/x-cmu-raster ras
image/x-cmx cmx
image/x-icon ico
image/x-portable-anymap pnm
image/x-portable-bitmap pbm
image/x-portable-graymap pgm
image/x-portable-pixmap ppm
image/x-rgb rgb
image/x-xbitmap xbm
image/x-xpixmap xpm
image/x-xwindowdump xwd
message/rfc822 mht
message/rfc822 mhtml
message/rfc822 nws
text/css css
text/h323 323
text/html htm
text/html html
text/html stm
text/iuls uls
text/plain bas
text/plain c
text/plain h
text/plain txt
text/richtext rtx
text/scriptlet sct
text/tab-separated-values tsv
text/webviewhtml htt
text/x-component htc
text/x-setext etx
text/x-vcard vcf
video/mpeg mp2
video/mpeg mpa
video/mpeg mpe
video/mpeg mpeg
video/mpeg mpg
video/mpeg mpv2
video/quicktime mov
video/quicktime qt
video/x-la-asf lsf
video/x-la-asf lsx
video/x-ms-asf asf
video/x-ms-asf asr
video/x-ms-asf asx
video/x-msvideo avi
video/x-sgi-movie movie
x-world/x-vrml flr
x-world/x-vrml vrml
x-world/x-vrml wrl
x-world/x-vrml wrz
x-world/x-vrml xaf
x-world/x-vrml xof

按照文件扩展名排列的 Mime 类型列表

扩展名 类型/子类型
  application/octet-stream
323 text/h323
acx application/internet-property-stream
ai application/postscript
aif audio/x-aiff
aifc audio/x-aiff
aiff audio/x-aiff
asf video/x-ms-asf
asr video/x-ms-asf
asx video/x-ms-asf
au audio/basic
avi video/x-msvideo
axs application/olescript
bas text/plain
bcpio application/x-bcpio
bin application/octet-stream
bmp image/bmp
c text/plain
cat application/vnd.ms-pkiseccat
cdf application/x-cdf
cer application/x-x509-ca-cert
class application/octet-stream
clp application/x-msclip
cmx image/x-cmx
cod image/cis-cod
cpio application/x-cpio
crd application/x-mscardfile
crl application/pkix-crl
crt application/x-x509-ca-cert
csh application/x-csh
css text/css
dcr application/x-director
der application/x-x509-ca-cert
dir application/x-director
dll application/x-msdownload
dms application/octet-stream
doc application/msword
dot application/msword
dvi application/x-dvi
dxr application/x-director
eps application/postscript
etx text/x-setext
evy application/envoy
exe application/octet-stream
fif application/fractals
flr x-world/x-vrml
gif image/gif
gtar application/x-gtar
gz application/x-gzip
h text/plain
hdf application/x-hdf
hlp application/winhlp
hqx application/mac-binhex40
hta application/hta
htc text/x-component
htm text/html
html text/html
htt text/webviewhtml
ico image/x-icon
ief image/ief
iii application/x-iphone
ins application/x-internet-signup
isp application/x-internet-signup
jfif image/pipeg
jpe image/jpeg
jpeg image/jpeg
jpg image/jpeg
js application/x-javascript
latex application/x-latex
lha application/octet-stream
lsf video/x-la-asf
lsx video/x-la-asf
lzh application/octet-stream
m13 application/x-msmediaview
m14 application/x-msmediaview
m3u audio/x-mpegurl
man application/x-troff-man
mdb application/x-msaccess
me application/x-troff-me
mht message/rfc822
mhtml message/rfc822
mid audio/mid
mny application/x-msmoney
mov video/quicktime
movie video/x-sgi-movie
mp2 video/mpeg
mp3 audio/mpeg
mpa video/mpeg
mpe video/mpeg
mpeg video/mpeg
mpg video/mpeg
mpp application/vnd.ms-project
mpv2 video/mpeg
ms application/x-troff-ms
mvb application/x-msmediaview
nws message/rfc822
oda application/oda
p10 application/pkcs10
p12 application/x-pkcs12
p7b application/x-pkcs7-certificates
p7c application/x-pkcs7-mime
p7m application/x-pkcs7-mime
p7r application/x-pkcs7-certreqresp
p7s application/x-pkcs7-signature
pbm image/x-portable-bitmap
pdf application/pdf
pfx application/x-pkcs12
pgm image/x-portable-graymap
pko application/ynd.ms-pkipko
pma application/x-perfmon
pmc application/x-perfmon
pml application/x-perfmon
pmr application/x-perfmon
pmw application/x-perfmon
pnm image/x-portable-anymap
pot, application/vnd.ms-powerpoint
ppm image/x-portable-pixmap
pps application/vnd.ms-powerpoint
ppt application/vnd.ms-powerpoint
prf application/pics-rules
ps application/postscript
pub application/x-mspublisher
qt video/quicktime
ra audio/x-pn-realaudio
ram audio/x-pn-realaudio
ras image/x-cmu-raster
rgb image/x-rgb
rmi audio/mid
roff application/x-troff
rtf application/rtf
rtx text/richtext
scd application/x-msschedule
sct text/scriptlet
setpay application/set-payment-initiation
setreg application/set-registration-initiation
sh application/x-sh
shar application/x-shar
sit application/x-stuffit
snd audio/basic
spc application/x-pkcs7-certificates
spl application/futuresplash
src application/x-wais-source
sst application/vnd.ms-pkicertstore
stl application/vnd.ms-pkistl
stm text/html
svg image/svg+xml
sv4cpio application/x-sv4cpio
sv4crc application/x-sv4crc
swf application/x-shockwave-flash
t application/x-troff
tar application/x-tar
tcl application/x-tcl
tex application/x-tex
texi application/x-texinfo
texinfo application/x-texinfo
tgz application/x-compressed
tif image/tiff
tiff image/tiff
tr application/x-troff
trm application/x-msterminal
tsv text/tab-separated-values
txt text/plain
uls text/iuls
ustar application/x-ustar
vcf text/x-vcard
vrml x-world/x-vrml
wav audio/x-wav
wcm application/vnd.ms-works
wdb application/vnd.ms-works
wks application/vnd.ms-works
wmf application/x-msmetafile
wps application/vnd.ms-works
wri application/x-mswrite
wrl x-world/x-vrml
wrz x-world/x-vrml
xaf x-world/x-vrml
xbm image/x-xbitmap
xla application/vnd.ms-excel
xlc application/vnd.ms-excel
xlm application/vnd.ms-excel
xls application/vnd.ms-excel
xlt application/vnd.ms-excel
xlw application/vnd.ms-excel
xof x-world/x-vrml
xpm image/x-xpixmap
xwd image/x-xwindowdump
z application/x-compress
zip application/zip
分享到:
评论

相关推荐

    ASP.NET通过HTML的上传文件标签来上传文件

    ASP.NET 是微软开发的一种用于构建...这个过程可以扩展到包含更多功能,如文件预览、多文件上传和进度跟踪,以满足各种项目需求。通过阅读和学习相关资源,如提供的博客链接,开发者能够深入理解并熟练应用这些技术。

    前端Javascript+Html5+后端PHP分块上传文件

    1.实现断点续传,已上传过的块,前端直接过滤掉,无需继续传到后端,加速上传效率,减少带宽 2.实现快速上传,即之前上传过,该文件已经存在的,很快就能上传成功,其原理就是文件md5+文件sha1的判断

    html文件上传后,处理类对上传文件的jar包处理

    html文件上传后,处理类对上传文件的jar包处理html文件上传后,处理类对上传文件的jar包处理html文件上传后,处理类对上传文件的jar包处理html文件上传后,处理类对上传文件的jar包处理html文件上传后,处理类对上传...

    在html页面使用JavaScript实行文件上传到本地服务器并获取文件所在路径

    使用JavaScript实现文件上传到本地服务器并获取到上传后文件所在路径,是由到JavaScript,java以及html页面。这个比较好,不是在jsp上获取路径,jsp太简单了,而且过时了,所以就在html页面实现了下功能,我主要是做...

    功能强大的文件上传组件

    【标题】"功能强大的文件上传组件"涉及到的核心技术是HTML5中的文件上传API,这是一个现代Web应用中不可或缺的功能,尤其在交互丰富的网站和应用程序中。HTML5的File API提供了更灵活、更强大的文件处理能力,使得...

    上传文件demo.html

    上传文件demo.html

    html5文件上传插件

    HTML5文件上传插件是一种基于Web技术实现的前端交互组件,它允许用户在网页上方便地上传文件到服务器,尤其适用于后台文件管理、图片展示、多媒体资源上传等场景。随着HTML5技术的发展,文件上传功能得到了显著提升...

    html网页js打开文件对话框带预览框.JS实现文件上传前先本地预览功能

    通过结合HTML5的`FileReader` API和JavaScript事件处理,我们可以轻松实现文件上传前的本地预览功能,提高用户交互体验,确保用户在上传文件前能够确认其内容。 此外,网络上的资源如"js读取input[type=file]图片,...

    HTML上传文件的3种实现方法.1用flash上传文件2用js插件上传文件3用表单上传文件

    HTML实现文件上传的3种实现方法 1用flash上传文件 2用js插件上传文件 3用表单上传文件

    jquery+ajaxfileupload+html文件上传

    - 对于大文件上传,考虑分块上传和断点续传,以提高用户体验和稳定性。 通过以上步骤,我们可以创建一个基本的基于jQuery、AjaxFileUpload和HTML的文件上传系统。这个系统不仅可以实时反馈上传状态,还能避免页面...

    html5文件上传器演示

    不需要任何浏览器插件,但需要和jQuery框架协同工作,支持超大文件上传,其算法是将一个超大文件切片成N个数据块依次提交给服务端处理,由服务端存储断点信息实现断点续传的功能;支持文件拖拽上传,直接将文件拖拽...

    Html上传文件类型、大小限制

    Html上传文件类型、大小限制

    html post上传文件

    HTML文件上传功能是Web开发中的常见需求,它允许用户通过网页选择本地文件并发送到服务器。这个过程通常涉及HTML表单、HTTP协议以及后端处理程序。以下是对这个主题的详细解释: 一、HTML表单 HTML中的`&lt;form&gt;`元素...

    Html5前端图片文件上传

    HTML5前端图片文件上传是一项重要的Web开发技术,它允许用户在不离开网页的情况下直接上传图片,极大地提升了用户体验。这项技术的实现主要依赖于HTML5的新特性,如File API、FormData对象以及XMLHttpRequest Level ...

    php+html5实现无刷新上传,大文件分片上传,断点续传

    在前端,我们可以监听文件输入元素的change事件,获取到文件后,创建FormData对象并添加文件,然后使用XMLHttpRequest的send方法发送到后台。PHP接收这些数据,进行存储或者进一步处理。 2. **大文件分片上传**: ...

    基于bootstrap.3的文件上传效果, 可拖拽上传、预览的HTML5文件上传插件.zip

    文件上传插件通常使用HTML5的FormData对象,它可以将表单数据以键值对的形式发送到服务器,包括上传的文件。此外,FileReader API用于在浏览器中读取和显示本地文件内容,实现预览功能。配合AJAX,可以实现实时上传...

    HTML5+WebSocket实现多文件同时上传的实例

    4. **文件上传**:对于每个`FileInfo`对象,我们可以使用`FileReader`API读取文件块,并在`onload`事件中将数据转换为Base64字符串(或其他编码格式),然后通过WebSocket发送到服务器。在每次发送后更新`...

    html5实现的文件上传预览功能

    此外,HTML5还提供了FormData对象,它可以将文件和其他表单数据打包,通过XMLHttpRequest发送到服务器,实现真正的文件上传。在上传过程中,还可以利用`progress`事件来实时更新上传进度,提升用户体验。 总结来说...

    HTML网页端直传OSS(java版本)

    HTML网页端直传OSS(Object Storage Service)是一种在网页前端直接上传文件到阿里云OSS存储服务的技术,常用于构建高效、便捷的文件上传功能。在这个Java版本的实现中,我们将探讨如何利用Java后端配合HTML前端,...

    asp.net上传文件的两种方式 普通html控件 服务器控件

    - `HttpPostedFileBase`接口代表了上传的文件对象,可以获取文件名、大小等信息,并将其保存到服务器。 - 使用服务器控件`FileUpload`,可以更方便地进行服务器端的验证和错误处理,因为它自动处理了文件流的读取。 ...

Global site tag (gtag.js) - Google Analytics