Quickly solve the problem of slow and stuck opening of input[type=file]

Quickly solve the problem of slow and stuck opening of input[type=file]

Why is it that when the input tag type is file and the attribute accpet="image/*" is set in the tag, the speed of opening the local folder is particularly slow?

After testing, I found that there is no lag problem in Safari, Firefox, and Chrome (Opera always crashes for some reason) on Mac.

In Windows, Firefox does not lag, only Chrome lags.

So I decided to remove accpet first...

Sure enough, there was no lag problem.

Then this package tried accpet="image/jpg" and it really didn't get stuck! !

It seems that the problem is "image/*"

But the original intention of writing accpet was to filter out all the pictures_(:з」∠)_

In order to achieve this requirement and improve user experience, we can only use enumeration.

Modified code

<input type="file" accpet="image/gif,image/png,image/jpeg,image/jpg,image/bmp"/>

Try it again, and it works fine!

It turns out that this is because Chrome's SafeBrowsing feature checks files when uploading or saving.

If the network connection to Google is fast, there will be no problem.

But if the connection is slow or down, SafeBrowsing will hang Chrome for a while until the file check is completed or times out.

Using accept="image/png, image/jpeg, image/gif" can solve this problem, because these MIME types are in the SafeBrowsing whitelist and do not need to be checked.

But if you use something like accept="image/*" , it won't work and it may become stuck.

The above article on how to quickly solve the problem of slow and stuck opening of input[type=file] is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

<<:  RHCE installs Apache and accesses IP with a browser

>>:  How to strike a balance between ease of use and security in the login interface

Recommend

Detailed explanation of Vue life cycle

Table of contents Why understand the life cycle W...

React-Native environment setup and basic introduction

Environment Preparation 1. Environment Constructi...

Two ways to manage volumes in Docker

In the previous article, I introduced the basic k...

CSS3 creates 3D cube loading effects

Brief Description This is a CSS3 cool 3D cube pre...

Vue Page Stack Manager Details

Table of contents 2. Tried methods 2.1 keep-alive...

How to modify mysql to allow remote connections

Regarding the issue of MySQL remote connection, w...

Beginners learn some HTML tags (2)

Beginners can learn HTML by understanding some HT...

A Brief Analysis of MySQL Connections and Collections

Join query A join query refers to a matching quer...

Eclipse configures Tomcat and Tomcat has invalid port solution

Table of contents 1. Eclipse configures Tomcat 2....

Tutorial on installing MySQL 5.6 using RPM in CentOS

All previous projects were deployed in the Window...

How to configure Nginx load balancing

Table of contents Nginx load balancing configurat...

Loading animation implemented with CSS3

Achieve results Implementation Code <h1>123...

Public free STUN servers

Public free STUN servers When the SIP terminal us...

Implementation of socket options in Linux network programming

Socket option function Function: Methods used to ...