Solution of HTML5 File.type value anomaly caused by WPS2013

Source: Internet
Author: User
Tags file upload

The compatibility of the processing code is a common occurrence for the front-end siege engineers, which are generally compatible with various browsers. But sometimes we also encounter factors outside the browser that are often overlooked. For example, a few days ago heard that the client installation thunder, Storm audio and video software will modify the number of HTTP connections, thus affecting the number of HTTP concurrency browser. Today, I was lucky enough to see another program compatibility problem caused by client installation of individual software. The culprit is Jinshan WPS2013.

The beginning of the story is like this ... I used HTML5 to write a file upload plug-in, which uses the file API, when validating the type of files using the file MIME type File.type get, if the obtained value in the Allow list, let it pass validation. Plugin finished, applied to the project, submitted the test, everything went well.

Then today, a test mm came to me, said file upload function is not so, obviously chose a word file, but prompted "file type is not allowed." At first I was dismissive, thought it must be her operation has a problem, but when I personally tried it, found that there is indeed a problem! An ordinary Word file, what can be strange? So I follow the process to print out some debugging information, found a big conspiracy, in the test mm machine, The MIME type of the word file obtained is application/kswps. It is not the normal application/msword of doc files, or the application/vnd.openxmlformats-officedocument.wordprocessingml.document of docx files. Then asked sister's machine is not installed Jinshan WPS, got the affirmative answer. It is easy to see from the name that the MIME type of the file was modified by the Kingsoft WPS (although the file was created with Microsoft Office). There is a picture of the truth:

WPS is not installed, the type of doc and docx files obtained is normal

After installing WPS2013, the type of doc and docx files becomes application/kswps

Because there is no such value in my Allow list, it cannot be validated. Solutions with toes can be thought out, this application/kswps also add to allow the list is not OK ~ just I thought this solved the problem ready to unload off WPS, who knows the story has not ended ... Please see the type value I get when I uninstall the WPS:

No, no! No, it's empty! What the hell did you do to my computer? I can't get the type value, so how do I verify it?

I then modified the file type validation by checking the suffix name so that it wouldn't be disturbed by MIME type inconsistencies. Although the problem is resolved, but the heart has always left a trace of Jinshan wps puzzled. In addition, the above situation only appears in Jinshan WPS current version 9.1, namely WPS2013. I tried to install the 8.1 version, there is no such phenomenon. I wonder if Jinshan WPS will notice this problem.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.