Javascript BlueImp jQuery文件上载-返回缩略图URL
我正在尝试从jQuery File Upload BlueImp的fileupload模块返回缩略图URL 这是我的上传脚本:Javascript BlueImp jQuery文件上载-返回缩略图URL,javascript,php,jquery,file-upload,blueimp,Javascript,Php,Jquery,File Upload,Blueimp,我正在尝试从jQuery File Upload BlueImp的fileupload模块返回缩略图URL 这是我的上传脚本: <script> /*jslint unparam: true */ /*global window, $ */ $(function () { 'use strict'; // Change this to the location of your server-side upload handler: var url = 'ser
<script>
/*jslint unparam: true */
/*global window, $ */
$(function () {
'use strict';
// Change this to the location of your server-side upload handler:
var url = 'server/php/';
$('#fileupload').fileupload({
url: url,
dataType: 'json',
done: function (e, data) {
$.each(data.result.files, function (index, file) {
$('<div class="box">').appendTo('#files');
$('.box').last().html('<a href="'+file.url+'"><img width="220px" height="120px" src="'+file.url+'"/></a>
});
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .progress-bar').css(
'width',
progress + '%'
);
}
}).prop('disabled', !$.support.fileInput)
.parent().addClass($.support.fileInput ? undefined : 'disabled');
});
</script>
/*jslint:正确*/
/*全局窗口,$*/
$(函数(){
"严格使用",;
//将此更改为服务器端上载处理程序的位置:
var url='server/php/';
$('#fileupload')。fileupload({
url:url,
数据类型:“json”,
完成:功能(e,数据){
$.each(data.result.files,函数(索引,文件){
$(“”).appendTo(“#文件”);
$('.box').last().html('
});
},
progressall:功能(e、数据){
var progress=parseInt(data.loaded/data.total*100,10);
$('#progress.progress bar').css(
“宽度”,
进度+“%”
);
}
}).prop('disabled',!$.support.fileInput)
.parent().addClass($.support.fileInput?未定义:“已禁用”);
});
如您所见,我可以返回“file.url”(示例:)
但我希望像这样返回“file.thumbnailURL”(示例:)
$('.box').last().html('<a href="'+file.url+'"><img width="220px" height="120px" src="'+file.thumbnailURL+'"/></a>
$('.box').last().html('
但它没有定义(我知道)
那么我如何定义file.thumbnailURL呢?定义file.url file.name的代码在哪里
谢谢你,
David。您的php脚本是否创建了缩略图?您可以
console.log(data)
并检查它是否是响应的一部分。谢谢,我发现缩略图URL是使用控制台定义为file.thumbnailUrl的。
// try
+ data.files[0].thumbnailUrl +
// or
+ data.files.thumbnailUrl +
// It worked for me