选择多个导致“错误”;“不安全的Javascript尝试”;
嗨,我在试着让采摘员工作。文件将在Chrome控制台中返回以下两个错误时将find上传到我的S3 bucket: 不安全的JavaScript试图使用URL访问帧file://localhost/Users/ben/fpiotest.html 从带有URL*#/computer/的框架。域、协议和端口必须匹配。 swfobject_src.js:1 未捕获的FilepickerException:获取元数据的文件无效:0。不是文件选择器url或FPFile对象。js:1 我的页面的整个代码如下:选择多个导致“错误”;“不安全的Javascript尝试”;,javascript,filepicker.io,Javascript,Filepicker.io,嗨,我在试着让采摘员工作。文件将在Chrome控制台中返回以下两个错误时将find上传到我的S3 bucket: 不安全的JavaScript试图使用URL访问帧file://localhost/Users/ben/fpiotest.html 从带有URL*#/computer/的框架。域、协议和端口必须匹配。 swfobject_src.js:1 未捕获的FilepickerException:获取元数据的文件无效:0。不是文件选择器url或FPFile对象。js:1 我的页面的整个代码如下:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="jquery-1.8.2.js"></script>
<!-- Adds the Filepicker.io javascript library to the page -->
<script src="https://api.filepicker.io/v1/filepicker.js"></script>
<script src="https://api.filepicker.io/v1/filepicker_debug.js"></script>
<script type="text/javascript">
//Seting up Filepicker.io with your api key
filepicker.setKey('<removed>');
</script>
</head>
<button style="margin-top: 35px" class="btn btn-primary" data-name="complex get"
onClick="filepicker.pickMultiple(
{
mimetype: 'image/*',
'container':'modal',
'metadata': true,
'services': ['COMPUTER', 'FACEBOOK', 'DROPBOX', 'FLICKR']
},
function(files){
var str = '';
//$('#multiResult').html(JSON.stringify(files));
for(var file in files) {
filepicker.stat(file, {size: true, filename: true, width: true, height: true, uploaded: true},
function(metadata){str += JSON.stringify(metadata);});
}
alert(str);
},
function(err){alert('error: ' + err);});">Run Code</button>
<!--function(response){$('#multiResult').html(JSON.stringify(response))});">Run Code</button>-->
<div class="row-fluid">
<div class="span2"><strong>Result:</strong></div>
<div class="span10">
<pre id="multiResult"></pre>
</div>
</div>
</html>
//使用api密钥设置Filepicker.io
filepicker.setKey(“”);
运行代码
结果:
看起来您被for-in循环卡住了。“files”是一个数组,所以第一个键是0,数组中的索引。我建议您:
for (var i = 0; i < files.length; i++) {
filepicker.stat(files[i], ...
}
for(var i=0;i
编辑:请确保在回调发生后也发出警报。出于好奇,请参阅您使用的浏览器 我们在IE9上遇到了一个类似的问题,其症状与控制台中的警告完全相同——文件被上传,但S3存储调用以某种方式失败
不清楚这是什么问题,因为它在Chrome上运行得很好。Brett:感谢您对此的快速回复。这解决了我在控制台中看到的第二个错误。但是“不安全的Javascript尝试…”问题仍然存在。对此有什么想法吗?这很可能与导致问题的闪存回退有关-一切都正常吗?这就解决了问题。谢谢!移动警报是解决第一个问题的方法。斯皮罗斯:很抱歉以前没有注意到你的问题。我在使用Chrome。