Forum Replies Created

Viewing 1 replies (of 1 total)
  • You can modify wpcf7-dropbox-script.js, in js directory of this plugin, using forEacn like beneath.

    jQuery(document).ready(function() {
        wpcf7_dropbox_mailsent_handler();
    });
    
    function wpcf7_dropbox_mailsent_handler() {
    	document.addEventListener( 'wpcf7mailsent', function( event ) {
    		form = wpcf7_dropbox_forms [ event.detail.contactFormId ];
    
    		if ( form.access_token && form.file_input ) {
    			var accessToken = form.access_token;
    			var dbx = new Dropbox({ accessToken: accessToken });
    
          var inputs = form.file_input.split(' ');
    
          inputs.forEach(function(val,index){
            var fileInput = document.getElementById(inputs[index]);
      			var file = fileInput.files[0];
      			if(file) {
      				dbx.filesUpload({path: '/' + file.name, contents: file})
      				.then(function(response) {
      				  console.log(response);
      				  console.log('File uploaded!');
      				})
      				.catch(function(error) {
      				  console.error(error);
      				});
      			}
          })
    		}
    		return false;
    
    	}, false );
    }
    

    In this case, I use space for delimiter, so you have to fill the “file input id” like “file1 file2”.

Viewing 1 replies (of 1 total)