javascriptfilepicker.io

Filepicker - Modals opens on page load


I'm integrating Filepicker into a form on a web page. Everything is working fine but I cannot stop the modal from opening by itself on each page load. I can't find a way of disabling this.

Here's the set up I'm playing with at the moment:

<script>
    // Set up the API key
    filepicker.setKey("XXXXXXX");

    filepicker.pickAndStore(
        // picker_options
        {
            openTo: 'COMPUTER',
            services: ['CLOUDDRIVE','COMPUTER','DROPBOX','FACEBOOK','GITHUB','GOOGLE_DRIVE','GMAIL','SKYDRIVE','URL','FTP','CLOUDAPP'],
            maxSize: 20971520,
        },
        // store_options
        {

        },
        function(Blobs){
            console.log(JSON.stringify(Blobs));
        },
        function(error){
            console.log(JSON.stringify(error));
        },
        function(progress){
            console.log(JSON.stringify(progress));
        }
    );
</script>

Same thing happens on codepen so it's nothing in the rest of the page that causes it.


Solution

  • Since you're picking a file, you should have the action of the pickAndStore function within the function called when you click a button to activate it.

    var button = document.getElementById('filePick');
    button.onclick(function() {
        filepicker.pickAndStore({
            //etc.
        });
    });