1

I'm trying to use this plugin http://valums.com/ajax-upload/. I added a file-limit, I want to disable the upload button (not hide, just disable). E.g.

if(filesNumber>=limit)
{
    //Disable the "Upload a file" button    
}

So, if the user will try to upload another file, he should see a message that the limit is exceeded. Can you look at this plugin and help me?

The button is not a form button, it is a div with css.

var btnUpload=$('#<?=$filesManagerCode?>upload');
        new AjaxUpload(btnUpload, {
            action: '<?=$boxLink?>actionMode<?=LDTR?>addfile',
            name: 'uploadFile[FilePath]',
            onSubmit: function(file, ext){
                btnUpload.attr('oldContent', btnUpload.html());
                btnUpload.html('<img src="'+jsloader.src+'"/>');
            },
            onComplete: function(file, response, temp){
                btnUpload.html(btnUpload.attr('oldContent'));
                $("#<?=$filesManagerCode?>files").load('<?=$boxLink?>', setFilesLimit(<?=$params['filesLimit']?>));
            }
        });


<div id="<?=$filesManagerCode?>upload" class="uploadButton"><span>Upload file</span> <span id="<?=$filesManagerCode?>uploadLimit"></span></div>

Thanks.

Denis Monn
  • 363
  • 4
  • 15

1 Answers1

0
    var btnUpload=$('#<?=$filesManagerCode?>upload');
           if(filesNumber>=limit)
{
    //Disable the "Upload a file" button or Do nothing:
       alert("You have reached the upload limit.");
}
else
{
            new AjaxUpload(btnUpload, {
                action: '<?=$boxLink?>actionMode<?=LDTR?>addfile',
                name: 'uploadFile[FilePath]',
                onSubmit: function(file, ext){
                    btnUpload.attr('oldContent', btnUpload.html());
                    btnUpload.html('<img src="'+jsloader.src+'"/>');
                },
                onComplete: function(file, response, temp){
                    btnUpload.html(btnUpload.attr('oldContent'));
                    $("#<?=$filesManagerCode?>files").load('<?=$boxLink?>', setFilesLimit(<?=$params['filesLimit']?>));

            });
}
The Muffin Man
  • 19,585
  • 30
  • 119
  • 191
  • No, it is not a form button, it is a
    with css. I should change the css class ( I can do this ) and I should to disable the browsing window, when it is clicked.
    – Denis Monn Feb 25 '11 at 21:14
  • @Denis, so your upload button isn't actually a button, it's a div? Can you post the click function for that button then? I can modify it for you. – The Muffin Man Feb 25 '11 at 21:16
  • Thanks, I added it. See my first post. – Denis Monn Feb 25 '11 at 21:21
  • Is your idea to run the AjaxUploader just in case the limit is not exceeded? I wanted to run it always, but your idea is also good. Thanks. I looked at this plugin and seen that there is a way to disable the uploader, but I can't do this... – Denis Monn Feb 25 '11 at 21:25
  • @Denis, I updated my answer. What do you mean by always run the ajax uploader? – The Muffin Man Feb 25 '11 at 21:54
  • Yes, I will use this way. Thanks. – Denis Monn Feb 25 '11 at 22:01