TCM
TCM

Reputation: 16900

Jquery uploadify plugin

I kept one jquery uploadify plugin on page and one <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 :)

Upvotes: 0

Views: 1509

Answers (3)

MartyIX
MartyIX

Reputation: 28648

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

Upvotes: 1

Ben Everard
Ben Everard

Reputation: 13804

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);
}

Upvotes: 0

Rosdi Kasim
Rosdi Kasim

Reputation: 25956

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

Upvotes: 0

Related Questions