我在遵循 jQuery 代码集成 filepicker.io 以上传单个图像文件时犯了什么错误?
What error I'm making in following jQuery code to integrate filepicker.io to upload a single image file?
我正在尝试将 filepicker.io 集成到我的 HTML 中以上传具有以下任一扩展名的图像:
jpeg/jpg/gif/png
为此,我编写了以下代码,但在 firebug 控制台中出现错误:
SyntaxError: missing : after property id
extension: '.jpeg:','.jpg:','.gif:','.png:',
以下是我完整的HTML代码供大家参考:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.2.min.js">
</script>
<script src="http://api.filepicker.io/v1/filepicker.js"></script>
<script>
$(document).ready(function() {
filepicker.setKey('AFJvi8ODOSrOayoCb3swoz');
document.getElementById('filepickerBtn').onclick = selectFile;
function selectFile() {
filepicker.pick(
// picker options
{
extension: '.jpeg:','.jpg:','.gif:','.png:',
},
onSuccessCallback
);
};
function onSuccessCallback(Blob){
document.getElementById('fileName').value = Blob.filename;
document.getElementById('fileLink').value = Blob.url;
document.getElementById('results').textContent = JSON.stringify(Blob);
};
});
</script>
</head>
<body>
<div class="container">
<h3>Filepicker example</h3>
<p>
<button id="filepickerBtn" class="btn btn-primary">
Select Image file
</button>
</p>
</div>
<form action="http://54.174.50.242/api/feed/addDocument" method="post">
<input type="text" name="fileName" value="" id="fileName">
<input type="text" name="fileLink" value="" id="fileLink">
<p>Results: <pre id="results">Upload file to see results</pre></p>
<input type="submit" name="Submit" value="Submit File">
</form>
</body>
</html>
提前致谢。
改变
filepicker.pick(
// picker options
{
extension: '.jpeg:','.jpg:','.gif:','.png:',
},
到
filepicker.pick(
// picker options
{
extension: ['.jpeg','.jpg','.gif','.png'],
},
我正在尝试将 filepicker.io 集成到我的 HTML 中以上传具有以下任一扩展名的图像:
jpeg/jpg/gif/png
为此,我编写了以下代码,但在 firebug 控制台中出现错误:
SyntaxError: missing : after property id
extension: '.jpeg:','.jpg:','.gif:','.png:',
以下是我完整的HTML代码供大家参考:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.2.min.js">
</script>
<script src="http://api.filepicker.io/v1/filepicker.js"></script>
<script>
$(document).ready(function() {
filepicker.setKey('AFJvi8ODOSrOayoCb3swoz');
document.getElementById('filepickerBtn').onclick = selectFile;
function selectFile() {
filepicker.pick(
// picker options
{
extension: '.jpeg:','.jpg:','.gif:','.png:',
},
onSuccessCallback
);
};
function onSuccessCallback(Blob){
document.getElementById('fileName').value = Blob.filename;
document.getElementById('fileLink').value = Blob.url;
document.getElementById('results').textContent = JSON.stringify(Blob);
};
});
</script>
</head>
<body>
<div class="container">
<h3>Filepicker example</h3>
<p>
<button id="filepickerBtn" class="btn btn-primary">
Select Image file
</button>
</p>
</div>
<form action="http://54.174.50.242/api/feed/addDocument" method="post">
<input type="text" name="fileName" value="" id="fileName">
<input type="text" name="fileLink" value="" id="fileLink">
<p>Results: <pre id="results">Upload file to see results</pre></p>
<input type="submit" name="Submit" value="Submit File">
</form>
</body>
</html>
提前致谢。
改变
filepicker.pick(
// picker options
{
extension: '.jpeg:','.jpg:','.gif:','.png:',
},
到
filepicker.pick(
// picker options
{
extension: ['.jpeg','.jpg','.gif','.png'],
},