My Blog

Multiple File Upload plugin for jQuery and IE7 and jQuery validation form - May 14th, 2008

All of you, maybe, know about this super Multiple File Upload. But when I start use it I have a strange things in IE7. I know it you could see it on the plugin website. (Select one file and the set focus again to this field or just try to upload another file).

bug

 

So have I fix this bug.

1. open jquery.MultiFile.js some with editors

2. after

        /// now let’s use jQuery
        slave = $(slave);

insert  this

        slave.attr("name",(slave.name || $(MASTER).attr(’name’) || ‘file’));
        slave.attr("id",(slave.id || MASTER.generateID(slave.i)));
        slave.val(”);
        slave.focus();

3. change

        // Remove element, remove label, point to current
                                        if(slave.i==0){
                                            $(MASTER.eCur).remove();
           MASTER.eCur = slave;
                                        }
                                        else{
                                            $(slave).remove();
                                        };

to

$(slave).remove();

 4. Thats all!

Now problem with jQuery validation plugin.

If you have a error message about that you should enter data less or equal some number.  You should replace all ".max" to ".maximum". Thats all too.

It was very helpful for me, so I hope it will be helpful for you!. If you have any question just ask me.

Tags: , ,

4 Responses to “Multiple File Upload plugin for jQuery and IE7 and jQuery validation form”

  1. webdev Says:

    You should send this fix to Diego so that he can incorporate these changes into the core plugin. He’s had it messed up in IE 7 since version 1.26. For some reason, setting an input field in IE 7 to val=” doesn’t work to clear a type=”file” input (at least according to my experimentation).

    Thank you very much for pointing out how to work around this issue.

  2. Diego Says:

    1. The problem was not in the logic of the plugin
    2. You work-around isn’t very reliable / neat

    I was able to reproduce this behaviour in IE7 and found that - for some reason - the browser was firing the onchange event twice: onchange and onblur.

    I fixed the problem by changing this code:
    // Triggered when a file is selected
    $(slave).change(function(){

    …into this:
    // Triggered when a file is selected
    $(slave).change(function(){

    // Lose focus to stop IE7 firing onchange again
    $(this).blur();

    Please download the latest version of the plugin to avoid future version conflicts:
    http://www.fyneworks.com/jquery/multiple-file-upload/

    PS.: Would you care to explain why you think this plugin is so awful?

  3. BACRHR Says:

    Diego,

    Thanks for so quick response. I know that my solution of problem is not so good, but I was really need to fix this issue. Anyway thank to you for this very useful and very nice plugin! Lets make web-world better ;)

  4. QuocKien Says:

    Hi,
    Sorry for my stupid question. I am getting stuck in the reset feature of Multi file upload plug in. I use ajaxSubmit to submit my form and want the multifile upload to reset for new form insertion. Can you please help?

    Thanks in advance
    Kien

Leave a Reply

authimage