Re: How to clear the list of selected files in the plugin and in the "input file"?

1,780 views
Skip to first unread message

Konstantin

unread,
Sep 12, 2012, 3:32:40 AM9/12/12
to jquery-f...@googlegroups.com
Can someone help me?

Tony Abou-Assaleh

unread,
Sep 12, 2012, 3:37:09 AM9/12/12
to jquery-f...@googlegroups.com
Have you tried destroying and re-enabling the plugin? Something like (not tested):

$('#input-reset').click(function(e) {
  e.preventDefaults();
  $('#file-input').fileupload('destory');
  $('#file-input').fileupload(/* ... your options here ...*/);
});

Cheers,
TAA

-- 
Tony Abou-Assaleh, PhD
Co-founder and CTO, TitanFile Inc.

151 Charles St. W., Suite 100, Kitchener ON Canada N2G 1H6

On Wed, Sep 12, 2012 at 3:32 AM, Konstantin <rockc...@gmail.com> wrote:
Can someone help me?

--
You received this message because you are subscribed to the Google Groups "jQuery-File-Upload" group.
To post to this group, send email to jquery-f...@googlegroups.com.
To unsubscribe from this group, send email to jquery-fileupl...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Konstantin

unread,
Sep 13, 2012, 4:26:06 AM9/13/12
to jquery-f...@googlegroups.com
Doesn't work. When I press the button upload the files begin loading. list of files in the plugin is not cleared. How to clean them globally from the plugin?

Jesús Horacio Gouveia

unread,
Sep 14, 2012, 11:30:07 PM9/14/12
to jquery-f...@googlegroups.com
I have the same problem. When I upload an image that stays attached to the input file. How I can release the button image..

sorry for my writing

On Monday, September 10, 2012 7:25:31 AM UTC-4:30, Konstantin wrote:
There is a clear button, when clicking it it is necessary to clear the file field and the file list in a plug-in. how it to make? It isn't described in plug-in documentation.

html:
<form method="post">
  <input type="file" name="file[]" id="file-input" />
  <button id="input-submit" type="submit">Upload</button>
  <button id="input-reset" type="reset">Clear</button> 
</form>

js:
$("#file-input").fileupload({
   paramName: "file[]",
   singleFileUploads: true,
   limitMultiFileUploads: 1,
   sequentialUploads: true,
   url: "/files_upload",
   type: "POST",
   ...
   ...
   ...
});

ca...@msn.com

unread,
Dec 31, 2012, 11:52:53 AM12/31/12
to jquery-f...@googlegroups.com
Have you resolved this as I am trying to do the same thing - remove files from screen after upload and clear the form.
If you have found an answer can you post the solution?

Aaron Wardle

unread,
Sep 12, 2013, 4:27:15 AM9/12/13
to jquery-f...@googlegroups.com
Hi

Not sure if this helps but I had the same issue I basically had various tabs on my website so users could select different types of files to upload Audio / Images / Video etc and when the user changes the tab I wanted the file list to clear after much effort I found that just calling this worked for me

$("#fileupload").find(".files").empty();

Hope that helps

Aaron

Rolandow -

unread,
Jul 3, 2014, 8:18:20 AM7/3/14
to jquery-f...@googlegroups.com
This clear the list visually, but it doesn't clear the input tags. When you submit the form, it will still upload the files.

Op donderdag 12 september 2013 10:27:15 UTC+2 schreef Aaron Wardle:

joesel duazo

unread,
Mar 25, 2020, 7:51:07 AM3/25/20
to jQuery-File-Upload


Noong Miyerkules, Setyembre 12, 2012 ng 3:32:40 PM UTC+8, si Konstantin ay sumulat:
Can someone help me?


I had a similar problem where previously uploaded files were included in the next upload. Try the following solution.


On Add  Function just add "change" event of the file input element like below:

    $('#YourFileUploadElementId').change(function(e) {
         data.files.splice(0); // Clear All Existing Files
    });

Full Example Below:

    $('#YourFileUploadElementId').fileupload({
        // Some options
        add: function (e, data) {
            $('#YourFileUploadElementId').change(function(e) {
              data.files.splice(0); // Clear All Existing Files
            });
        },
        // Other Events
     });

Note: Just change the YourFileUploadElementId to your file upload element id.

Here is the complete example on jsfiddle.net

Reply all
Reply to author
Forward
0 new messages