<form>
<inputtype="file"name="pic"id="pic"accept="image/gif,image/jpeg"/>
</form>
accept属性只能与<inputtype="file">配合使用。它规定能够通过文件上传进行提交的文件类型。
值 描述
audio/* 接受所有的声音文件。
video/* 接受所有的视频文件。
image/* 接受所有的图像文件。
MIME_type 一个有效的MIME类型,不带参数。请参阅IANAMIME类型,获得标准MIME类型的完整列表。
accept可以指定如下信息:
*.3gpp audio/3gpp,video/3gpp 3GPPAudio/Video
*.ac3 audio/ac3 AC3Audio
*.asf allpication/vnd.ms-asf AdvancedStreamingFormat
*.au audio/basic AUAudio
*.css text/css CascadingStyleSheets
*.csv text/csv CommaSeparatedValues
*.doc application/msword MSWordDocument
*.dot application/msword MSWordTemplate
*.dtd application/xml-dtd DocumentTypeDefinition
*.dwg image/vnd.dwg AutoCADDrawingDatabase
*.dxf image/vnd.dxf AutoCADDrawingInterchangeFormat
*.gif image/gif GraphicInterchangeFormat
*.htm text/html HyperTextMarkupLanguage
*.html text/html HyperTextMarkupLanguage
*.jp2 image/jp2 JPEG-2000
*.jpe image/jpeg JPEG
*.jpeg image/jpeg JPEG
*.jpg image/jpeg JPEG
*.js text/javascript,application/javascript JavaScript
*.json application/json JavaScriptObjectNotation
*.mp2 audio/mpeg,video/mpeg MPEGAudio/VideoStream,LayerII
*.mp3 audio/mpeg MPEGAudioStream,LayerIII
*.mp4 audio/mp4,video/mp4 MPEG-4Audio/Video
*.mpeg video/mpeg MPEGVideoStream,LayerII
*.mpg video/mpeg MPEGVideoStream,LayerII
*.mpp application/vnd.ms-project MSProjectProject
*.ogg application/ogg,audio/ogg OggVorbis
*.pdf application/pdf PortableDocumentFormat
*.png image/png PortableNetworkGraphics
*.pot application/vnd.ms-powerpoint MSPowerPointTemplate
*.pps application/vnd.ms-powerpoint MSPowerPointSlideshow
*.ppt application/vnd.ms-powerpoint MSPowerPointPresentation
*.rtf application/rtf,text/rtf RichTextFormat
*.svf image/vnd.svf SimpleVectorFormat
*.tif image/tiff TaggedImageFormatFile
*.tiff image/tiff TaggedImageFormatFile
*.txt text/plain PlainText
*.wdb application/vnd.ms-works MSWorksDatabase
*.wps application/vnd.ms-works WorksTextDocument
*.xhtml application/xhtml+xml ExtensibleHyperTextMarkupLanguage
*.xlc application/vnd.ms-excel MSExcelChart
*.xlm application/vnd.ms-excel MSExcelMacro
*.xls application/vnd.ms-excel MSExcelSpreadsheet
*.xlt application/vnd.ms-excel MSExcelTemplate
*.xlw application/vnd.ms-excel MSExcelWorkspace
*.xml text/xml,application/xml ExtensibleMarkupLanguage
*.zip application/zip CompressedArchive
除了以上的类型外,2007后各文档如docx需配置的accept属性值如下:
ExtensionMIMEType
.xlsxapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xltxapplication/vnd.openxmlformats-officedocument.spreadsheetml.template
.potxapplication/vnd.openxmlformats-officedocument.presentationml.template
.ppsxapplication/vnd.openxmlformats-officedocument.presentationml.slideshow
.pptxapplication/vnd.openxmlformats-officedocument.presentationml.presentation
.sldxapplication/vnd.openxmlformats-officedocument.presentationml.slide
.docxapplication/vnd.openxmlformats-officedocument.wordprocessingml.document
.dotxapplication/vnd.openxmlformats-officedocument.wordprocessingml.template
.xlsmapplication/vnd.ms-excel.addin.macroEnabled.12
.xlsbapplication/vnd.ms-excel.sheet.binary.macroEnabled.12
如果您觉得本文的内容对您的学习有所帮助:
关键字:
HTML