开发者

Jquery uploadify plugin

I kept one jquery uploadify plugin on page and on开发者_如何学编程e <img> tag besides it. Everything works fine as expected except one problem. I want to update <img> to show the new image as soon as some image is uploaded. How can i do this? I am using Php.

Thanks in advance :)


You can use onComplete callback (http://www.uploadify.com/documentation/).

Usage sample is here:

$(document).ready(function() {
  $('#fileInput').uploadify({
    'uploader'  : 'uploadify.swf',
    'script'    : 'uploadify.php',
    'cancelImg' : 'cancel.png',
    'auto'      : true,
    'folder'    : '/uploads'

    /* ====== HERE ===== */
    'onComplete': function(event, queueID, fileObj, response, data) {       
        $("#my_image").attr("src","your path");
     }

  });
});

(http://www.uploadify.com/implementation/)


Just use JQuery to update the <img src="..." /> attribute of that image should do it IMHO.


Take a look at the documentation, it looks like the onComplete callback will return the file path, you could then do something like this:

onComplete: function(event, queueID, fileObj, response, data) {
    $('img#user_avatar').attr('src',fileObj.filePath);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜