FINEUPLOAD pass the ID as parameter

2019-08-22 03:36发布

i got this divs

<div id="thumbnail-uploader_1" class="thumbnail-uploader">
<div id="thumbnail-uploader_2" class="thumbnail-uploader">

and this Jquery call

$('.thumbnail-uploader').fineUploader({
request: {
    endpoint: '/core/ajax/add_avatar.php',
    params: {
    one: function() {
        return this.id;
     }
    }
},
multiple: false,
validation: {
    allowedExtensions: ['jpeg', 'jpg', 'gif', 'png'],
    sizeLimit: 551200 // 50 kB = 50 * 1024 bytes
},
text: {
    uploadButton: 'Klikněte nebo sem přetáhněte soubor'
}
}).on('complete', function(event, id, fileName, responseJSON) {
if (responseJSON.success) {
    $(this).append('<img src="/uploads/categories/' + fileName + '" alt="' + fileName + '">');
    $('.qq-upload-list').fadeOut(2500);
}
});

all i want to do is to pass the ID of the used uploader. but with this call, i got undefined value of the parameter "one" when i try to use it in "add_avatar.php" which is handler. i use the global array REQUEST over there to check if the value pass. but its undefined.

does anyone have some idea how to pass the ID in my php script? i will have more instances of this uploader there so i have to check for which record im changing the avatar.

2条回答
乱世女痞
2楼-- · 2019-08-22 04:03

Since you are using jQuery, maybe this is what you are looking for.

return $(this).attr('id');
查看更多
疯言疯语
3楼-- · 2019-08-22 04:11

i solved it by creating the jquery calls for every iterations of category and i changed the selector from class to ID like:

$('#thumbnail-uploader_1').fineUploader({.....
$('#thumbnail-uploader_2').fineUploader({.....
查看更多
登录 后发表回答