I'm trying to return the thumbnails URL from fileupload module of jQuery File Upload BlueImp.

Here is my uploader script :

<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>

As you see I can return the "file.url" (example : http://website.com/server/php/files/image.png ) But I would like to return the "file.thumbnailURL" (example : http://website.com/server/php/thumbnails/image.png ) like that

$('.box').last().html('<a href="'+file.url+'"><img width="220px" height="120px" src="'+file.thumbnailURL+'"/></a>

but it's undefined (I know about it) So how could I define the file.thumbnailURL? where is the code which define file.url file.name... ?

Thanks you, David.

有帮助吗?

解决方案

Does your php script create the thumbnails? You can console.log(data) and check whether it is part of the response or not.

其他提示

   // try
     + data.files[0].thumbnailUrl +   
  //  or 
     + data.files.thumbnailUrl +   
   // It worked for me
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top