Ajax 如何使用dropbox saver api将多个图像文件保存到dropbox?
我试图使用dropbox saver api将多个图像保存到dropbox,但我的代码没有保存图像,我没有收到任何错误和确认。(dropbox saver窗口弹出并单击save,它关闭,但没有确认!)有人能告诉我如何解决此问题吗 注意:我可以使用此函数调用保存一张图像:Ajax 如何使用dropbox saver api将多个图像文件保存到dropbox?,ajax,api,dropbox,dropbox-api,dropbox-php,Ajax,Api,Dropbox,Dropbox Api,Dropbox Php,我试图使用dropbox saver api将多个图像保存到dropbox,但我的代码没有保存图像,我没有收到任何错误和确认。(dropbox saver窗口弹出并单击save,它关闭,但没有确认!)有人能告诉我如何解决此问题吗 注意:我可以使用此函数调用保存一张图像: Dropbox.save('<?PHP echo $imagePath1_Value; ?>', 'image1.jpg', options); Dropbox.save(“”,'image1.jpg',选项);
Dropbox.save('<?PHP echo $imagePath1_Value; ?>', 'image1.jpg', options);
Dropbox.save(“”,'image1.jpg',选项);
完整代码:
<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>
函数保存程序(){
变量选项={
档案:[
//最多可以指定100个文件。
// ...
{'url':'','filename':'1.jpg'},
{'url':'','filename':'2.jpg'},
{'url':'','filename':'3.jpg'},
],
//将所有文件成功添加到用户的文件夹后,将调用Success
//Dropbox,尽管它们可能尚未同步到用户的设备。
成功:函数(){
//向用户指示文件已保存。
警报(“成功!文件已保存到您的Dropbox。”);
},
//定期调用Progress以更新应用程序的进度
//用户下载的。传递给此回调的值是浮点值
//介于0和1之间。保证至少调用进度回调
//一次,值为1。
进展:职能(进展){},
//如果用户按下取消按钮或关闭保存程序,则调用Cancel。
取消:函数(){},
//在服务器出现意外响应时调用Error
//托管文件,例如找不到文件。此回调是
//如果Dropbox出现错误或用户超出配额,也会调用此函数。
错误:函数(errorMessage){}
};
Dropbox.save(选项);
};
保存(多个图像)
此代码看起来基本正常。正在调用错误回调吗?您能记录errorMessage
的值吗?谢谢您的回复。我如何检查是否调用了错误回调以及如何记录错误消息的值?在保存窗口中单击“保存”后,页面中不会显示任何错误!只需将代码添加到错误处理程序中。例如,error:function(errorMessage){alert(“error:+errorMessage”);}
谢谢它帮助我解决了这个问题。问题是两个文件的名称相同!我是否将文件URL放在动态数组中并使用数组调用保护程序功能?