[英]Dropbox Chooser to upload files from user's dropbox account
Hi I am implementing the functionality in which users can upload pictures from their dropbox account. 嗨,我实现了用户可以从其保管箱帐户上传图片的功能。 For that I found Dropbox Chooser, which helps to upload the files form our dropbox account.
为此,我找到了Dropbox Chooser,它有助于从我们的Dropbox帐户上传文件。 Following is the code, used dropbox chooser documentation.
以下是代码,用于保管箱选择器文档。 When I click on button, it supposed to open the window with the dropbox login screen.
当我单击按钮时,它应该使用保管箱登录屏幕打开该窗口。 I get the dropbox screen but with the message 'Sorry for this little hiccups.... please try to relaod the page'.
我得到了保管箱屏幕,但显示消息“对不起,这个小问题……。请尝试重新修饰页面”。 I found some similar problems forums and followed their solutions.
我发现了一些类似的问题论坛,并遵循了他们的解决方案。 Ofcourse, none worked.
当然,没有一个有效。 Any help is appreciated and would be great.
任何帮助,将不胜感激。 TIA
TIA
Index.php Index.php
<div id="dropbox-upload-container"></div>
<script type="text/javascript" src="https://www.dropbox.com/static/api/2/dropins.js" id="dropboxjs" data-app-key="wgiv8kvzvq57mlw"></script>
<script type="text/javascript">
options = {
success: function(files) {
files.forEach(function(file) {
// add_img_to_list(file);
});
},
cancel: function() {
//optional
},
linkType: "preview", // "preview" or "direct"
multiselect: true, // true or false
extensions: ['.png', '.jpg'],
};
var button = Dropbox.createChooseButton(options);
document.getElementById("dropbox-upload-container").appendChild(button);
</script>
Can avoid this error by setting the html page with in the server. 通过在服务器中设置html页面可以避免此错误。 For this purpose, I used express - node.js.
为此,我使用了express-node.js。
Following is the snippet: finaltest.js 以下是代码段: finaltest.js
var express = require('express');
var app = express();
app.use(express.static('public'));
app.get('/', function (req, res) {
res.sendFile( __dirname + "/" + "finaltest.html" );
})
var server = app.listen(8081)
For html, js : https://codepen.io/sreepurna/pen/NYmMaj 对于html,js: https : //codepen.io/sreepurna/pen/NYmMaj
Now run the server - node finaltest.js 现在运行服务器- 节点finaltest.js
Go to the web browser and use http://localhost:8081 . 转到网络浏览器并使用http:// localhost:8081 。
Hope this helps!!!! 希望这可以帮助!!!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.