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 daily_routine example code in Linux

First look at the example code: #/bin/bash cal da...

Three examples of nodejs methods to obtain form data

Preface Nodejs is a server-side language. During ...

Detailed explanation of Mysql self-join query example

This article describes the Mysql self-join query....

How to use Navicat to operate MySQL

Table of contents Preface: 1. Introduction to Nav...

Summary of three ways to implement ranking in MySQL without using order by

Assuming business: View the salary information of...

MySQL database terminal - common operation command codes

Table of contents 1. Add users 2. Change the user...

What does this.parentNode.parentNode (parent node of parent node) mean?

The parent node of the parent node, for example, t...

JavaScript implements changing the color of a web page through a slider

Hello everyone, today when I was looking at the H...

JS implements simple addition and subtraction of shopping cart effects

This article example shares the specific code of ...

win2008 server security settings deployment document (recommended)

I had been working on the project before the New ...

Vue components dynamic components detailed explanation

Table of contents Summarize Summarize When the ar...

MySQL exposes Riddle vulnerability that can cause username and password leakage

The Riddle vulnerability targeting MySQL versions...

An example of implementing a simple finger click animation with CSS3 Animation

This article mainly introduces an example of impl...