Sign up to create your own snipts, or login.

Public snipts » mkelly12's snipts » AJAX avatar upload

posted on Feb 24, 2010 at 8:25 p.m. EST in 
  • $(document).ready(function(){
    
    	var thumb = $('img#thumb');	
    
    	new AjaxUpload('imageUpload', {
    		action: $('form#newHotnessForm').attr('action'),
    		name: 'image',
    		onSubmit: function(file, extension) {
    			$('div.preview').addClass('loading');
    		},
    		onComplete: function(file, response) {
    			thumb.load(function(){
    				$('div.preview').removeClass('loading');
    				thumb.unbind();
    			});
    			thumb.attr('src', response);
    		}
    	});
    });
    

    copy | embed

1 Comment

on Mar 22, 2010 at 10:31 a.m. EDT
I have made a revised version of the function here: http://www.unchi.co.uk/2010/03/21/image-upload-using-jquery-php-and-no-file-input/

It simplifies the screen to the user and allows unlimited number of thumbnails without needing an id for each.
Sign up, or login to leave a comment.