HTML5 form Upload Control files filter file in specified format: Accept property to filter Excel file

Source: Internet
Author: User

Excerpt from: http://blog.csdn.net/jyy_12/article/details/9851349

(IE9 and below do not support these features, the latest version of other browsers are supported.) )

1. Allow uploading of files

Allow multiple files to be selected: <input type= "File" multiple>

Allow only one file to be uploaded: <input type= "File" single>

2, upload the specified file format

<input type= "file" accept= "image/gif,image/png" />

The upload format here refers to the default file format when you open the upload pop-up selection file, and can be manually modified to other file formats.

If you do not limit the format of uploaded pictures can be written as: accept= "image/*"

Other format references are as follows:

*.3gpp AUDIO/3GPP, VIDEO/3GPP 3GPP Audio/video
*.ac3 Audio/ac3 AC3 Audio
*.asf allpication/vnd.ms-asf Advanced Streaming Format
*.au Audio/basic AU Audio
*.css Text/css Cascading Style Sheets
*.csv Text/csv Comma separated Values
*.doc Application/msword MS Word Document
*.dot Application/msword MS Word Template
*.dtd Application/xml-dtd Document Type Definition
*.dwg Image/vnd.dwg AutoCAD Drawing Database
*.dxf image/vnd.dxf AutoCAD Drawing Interchange Format
*.gif Image/gif Graphic Interchange Format
*.htm text/HTML Hypertext Markup Language
*. HTML text/HTML Hypertext Markup Language
*.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 JavaScript Object Notation
*.mp2 Audio/mpeg, Video/mpeg MPEG audio/video Stream, Layer II
*.mp3 Audio/mpeg MPEG Audio Stream, Layer III
*.mp4 Audio/mp4, Video/mp4 MPEG-4 Audio/video
*.mpeg Video/mpeg MPEG Video Stream, Layer II
*.mpg Video/mpeg MPEG Video Stream, Layer II
*.mpp Application/vnd.ms-project MS Project Project
*.ogg Application/ogg, Audio/ogg Ogg Vorbis
*.pdf Application/pdf Portable Document Format
*.png Image/png Portable Network Graphics
*.pot Application/vnd.ms-powerpoint MS PowerPoint Template
*.pps Application/vnd.ms-powerpoint MS PowerPoint Slideshow
*.ppt Application/vnd.ms-powerpoint MS PowerPoint Presentation
*.rtf Application/rtf, Text/rtf Rich Text Format
*.svf Image/vnd.svf Simple Vector Format
*.tif Image/tiff Tagged Image Format File
*.tiff Image/tiff Tagged Image Format File
*. txt Text/plain Plain Text
*.wdb Application/vnd.ms-works MS Works Database
*.wps Application/vnd.ms-works Works Text Document
*.xHTML application/xHtml+xml Extensible Hypertext Markup Language
*.xlc Application/vnd.ms-excel MS Excel Chart
*.xlm Application/vnd.ms-excel MS Excel Macro
*.xls Application/vnd.ms-excel MS Excel Spreadsheet
*.xlt Application/vnd.ms-excel MS Excel Template
*.xlw Application/vnd.ms-excel MS Excel Workspace
*.xml Text/xml, Application/xml Extensible Markup Language
*.zip Aplication/zip Compressed Archive

Here to be careful to explain is: Many online tutorials have said that Excel filtering to use "accept=" Application/msexcel"", in fact, is a big mistake! It 's been tested, no! I am also doing phpexcel export Excel file Yes, see, there is a line of code:

Header (' Content-type:application/vnd.ms-excel '); //excel 2003

Header (' Content-type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet '); //excel

I just realized that the original. xls format file to use with this MIME type. Test, Success!

HTML5 form Upload Control files filter file in specified format: Accept property to filter Excel file

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.