Skip to content

Instantly share code, notes, and snippets.

@davemo
Created March 8, 2010 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davemo/325612 to your computer and use it in GitHub Desktop.
Save davemo/325612 to your computer and use it in GitHub Desktop.
$("#id_logo").uploadify({
'uploader' : '{% vurl "/static/script/vendor/uploadify/uploadify.swf" %}',
'script' : '{% url business-listing-logo company.key %}',
'cancelImg' : '{% vurl "/static/script/vendor/uploadify/cancel.png" %}',
'scriptAccess' : 'always',
'auto' : true,
'queueID' : 'fileQueue',
'fileDataName' : 'logo',
'sizeLimit' : 1000000, // ah, the old 1mb limit rears its head :(
onComplete : function(evt, queueID, file, response) {
// by default flash just returns a string, need to parse the object
// note: this can be refactored if/when we upgrade to jquery 1.4.2 as it has support built in
var response = YAHOO.lang.JSON.parse(response);
if(response.success) {
$.gritter.add({
title: 'Image Uploaded',
text: 'Your new logo has been uploaded!',
image: SREP.getVersionedImage("/static/compiledcss/images/form.success.png")
});
// update the source of the logo inline so they can see it.
$("#business-logo").attr("src", response.images[0]);
} else {
$.gritter.add({
title: 'Error Uploading Image',
text: response.errors[0],
image: SREP.getVersionedImage("/static/compiledcss/images/form.error.png")
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment