Home > Web Front-end > CSS Tutorial > Solution to the problem of slow opening and freezing of input[type=file]

Solution to the problem of slow opening and freezing of input[type=file]

巴扎黑
Release: 2017-08-12 15:06:39
Original
2403 people have browsed it

The following editor will bring you an article. The following editor will bring you an article to quickly solve the problem of slow and stuck input[type=file] when opening. The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor and take a look.

Why do we set attributes in the tag when the input tag type is file to upload a fileaccpet="image/*", open Are local folders particularly slow?

After testing, it was found that there is no lag problem in Safari, Firefox, and Chrome (opera doesn’t know why it keeps crashing) on ​​mac

In windows, Firefox does not lag, only Chrome Stuck and stopped.

So I decided to try removing accpet first...

Sure enough, there was no lag problem.

Then I’m trying this package outaccpet="image/jpg" Sure enough, it’s not stuck anymore! !

It seems that the problem is "image/*"

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

So in order to realize this requirement and improve the user experience at the same time, we can only enumerate the

modified code


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

Try it again, it’s really good!

It turns out that it’s because Chrome’s SafeBrowsing function checks files when uploading or saving.

What if the network connection to Google is faster? , there is no problem.

But if the connection is slow, or simply down, SafeBrowsing will let Chrome hang for a period of time until the file check ends or times out

Use accept= "image/png, image/jpeg, image/gif" can solve this problem, because these MIME types are in the whitelist of SafeBrowsing and are not needed examine.

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

The above is the detailed content of Solution to the problem of slow opening and freezing of input[type=file]. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template