Upload multiple files jquery. Multifile to clear the file list

Source: Internet
Author: User
Upload multiple files jquery. Multifile to clear the file list

When uploading multiple files, many people will use the jquery. Multifile plug-in. This plug-in is very useful. View my results.

You can delete an object separately. But I don't know if you have considered clearing all the file lists?

At the beginning, I was smart and thought that since the Code is automatically generated, why can't I directly Delete the code? (leave the code in a div empty .)? Think about it. The effect seems to be satisfactory. When the code is written, the problem is found.

What's the problem? Because the Multifile plug-in has a maximum number of files to control. On the surface, it seems that the file is clear. However, the internal file count counter is not cleared by colleagues. The most direct phenomenon is:

For example, if you set a maximum of five files and select five files, the file browsing button is automatically assigned to the disabled folder. Now that you have cleared the file, you cannot re-select the file.

What should we do?

I did not find this method on the Internet, but it was encapsulated by myself. The generated code is as follows:

The generated code shows the following connection:

<A class = "Multifile-Remove" href = "# upfile_warp"> in this connection, you can click this connection to delete a single file.

So try to write the following code:

Multifileclear = function (){
$ ("A. Multifile-Remove"). Each (function (I ){
This. Click ();

});
}

Test! OK!

 

------ Let's take a look at the jquery. mutlifile Code and provide a method.

/**
* This method removes all selected files
*
* Returns a jquery collection of all affected elements.
*
* @ Name Reset
* @ Type jquery
* @ Cat plugins/Multifile
* @ Author Diego A. (http://www.fyneworks.com /)
*
* @ Example $. FN. Multifile. Reset ();
*/
Reset: function (){
VaR settings = $ (this). Data ('multifile ');
// If (settings) settings. wrapper. Find ('A. Multifile-delete'). Click ();
If (settings) settings. List. Find ('A. Multifile-delete'). Click ();
Return $ (this );
},

Khan .. The idea is the same.

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.