• Resolved adzil

    (@adzil)


    This works nicely with 1 file. However in the CF7 form that I would like to use this with, there are 2 files to upload. Can both files be sent to dropbox? Thanks.

Viewing 4 replies - 1 through 4 (of 4 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”.

    So I modified the wpcf7-dropbox-script.js file the same way you that you have it above.

    In my form I use the following:
    ————————————–
    <label> Upload your Music
    [file* upload1 limit:20mb filetypes:mp3|wav|m4a|png|jpg|jpeg|gif id:file1] </label>
    <label> Upload your Artwork
    [file* upload2 limit:20mb filetypes:mp3|wav|m4a|png|jpg|jpeg|gif id:file2] </label>
    ————————————–

    Under my DropBox Settings I have:
    ————————————–
    File Input ID: file1 file2
    ————————————–

    But when I test it I get nothing? Am I doing something wrong?

    Plugin Author Jay Swadas

    (@jayswadas)

    Hi @adzil,

    Currently, multiple file uploading feature is not supported. I’ll definitely look into this.

    Thanks for your suggestion.

    Thanks,
    Jay Swadas

    Plugin Author Jay Swadas

    (@jayswadas)

    Check out Updated Version 1.2
    – Added “Dropbox Folder” field to upload file on specify dropbox folder.
    – Multiple file upload using multiple File Input Ids

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can this work with more than one file?’ is closed to new replies.