0

I am trying to save multiple images to dropbox using dropbox saver api but my code doesnt save the images and i dont get any error and no confirmation .(dropbox saver window pops up and click save and it closes but no confirmation!) could any one tell me how to fix this problem ?

Note: I am able to save one image using this function call:

Dropbox.save('<?PHP  echo $imagePath1_Value; ?>', 'image1.jpg', options);

full code:

<script type="text/javascript" src="https://www.dropbox.com/static/api/2/dropins.js" id="dropboxjs" data-app-key="xxxxxxxxxxxxxx"></script>
<script>

function saver(){

var options = { 

files: [
        // You can specify up to 100 files.
        // ...
        {'url': '<?PHP  echo $imagePath1_Value; ?>', 'filename': '1.jpg'},
        {'url': '<?PHP  echo $imagePath2_Value; ?>', 'filename': '2.jpg'},
        {'url': '<?PHP  echo $imagePath3_Value; ?>', 'filename': '3.jpg'},

    ],

    // Success is called once all files have been successfully added to the user's
    // Dropbox, although they may not have synced to the user's devices yet.
    success: function () {
        // Indicate to the user that the files have been saved.
        alert("Success! Files saved to your Dropbox.");
    },

    // Progress is called periodically to update the application on the progress
    // of the user's downloads. The value passed to this callback is a float
    // between 0 and 1. The progress callback is guaranteed to be called at least
    // once with the value 1.
    progress: function (progress) {},

    // Cancel is called if the user presses the Cancel button or closes the Saver.
    cancel: function () {},

    // Error is called in the event of an unexpected response from the server
    // hosting the files, such as not being able to find a file. This callback is
    // also called if there is an error on Dropbox or if the user is over quota.
    error: function (errorMessage) {}

};

Dropbox.save(options);
};
</script>
<button onclick="saver()">save(Multiple images)</button>
General Grievance
  • 4,555
  • 31
  • 31
  • 45
user1788736
  • 2,727
  • 20
  • 66
  • 110
  • This code looks largely okay. Is your error callback being called? Can you log the value of `errorMessage`? – user94559 Jun 09 '15 at 19:19
  • Thanks for reply .how i can check if error callback being called and how to log the value of error Message? no error shows in page after i click save on saver window! – user1788736 Jun 09 '15 at 20:08
  • 1
    Just add code to the error handler. E.g. `error: function (errorMessage) { alert("ERROR: " + errorMessage); }` – user94559 Jun 10 '15 at 02:25
  • Thanks it helped me fix the problem . Problem was two files were named same! Is there away that i place file urls in dynamic array and use that array call saver function ? – user1788736 Jun 10 '15 at 14:27

0 Answers0