Question

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.

Was it helpful?

Solution

    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']?>));

            });
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top