upload_avatar.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. var reorder = 0;
  2. function loadUpload(i,e,key,upload,assets)
  3. {
  4. e.uploadify({
  5. 'formData' : {'key' : key},
  6. 'swf' : assets + 'uploadify.swf',
  7. 'buttonText' : '选择文件',
  8. 'uploader' : upload,
  9. 'cancelImg' : assets + 'image/uploadify-cancel.png',
  10. 'width':'65',//选择文件按钮的宽度
  11. 'height':'65',//选择文件按钮的高度
  12. 'buttonText' : '',
  13. //'buttonClass' : 'update',
  14. 'onUploadSuccess':function(file,data,response)
  15. {
  16. console.info(data);
  17. var data = eval('('+data+')');
  18. if(data.status)
  19. {
  20. var value = e.attr('v');
  21. if(value.indexOf('mul') != -1 && $(value).length)
  22. {
  23. var img = '<img src="'+data.url+'" width="">';
  24. $(value).eq(reorder).html(img);
  25. $("#content").val($("#content").val() + "<br />" + img);
  26. reorder++;
  27. if(reorder > 5)
  28. {
  29. reorder = 0;
  30. }
  31. }
  32. else
  33. {
  34. jQuery("#"+file.id).find('.data').html('上传完毕');
  35. jQuery("#"+file.id).hide();
  36. jQuery('#'+value).val(data.url);
  37. jQuery('#show_'+value).attr('src',data.url).show();
  38. }
  39. }
  40. else
  41. {
  42. jQuery("#"+file.id).find('.data').html("<font color='red'>"+data.message+"</font>");
  43. return false;
  44. }
  45. }
  46. });
  47. }
  48. if(jQuery.browser.msie){
  49. SWFUpload.prototype.getFlashHTML = function () {
  50. return ['<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="', this.movieName, '" type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">',
  51. '<param name="wmode" value="', this.settings.button_window_mode , '" />',
  52. '<param name="movie" value="', this.settings.flash_url, '" />',
  53. '<param name="quality" value="high" />',
  54. '<param name="menu" value="false" />',
  55. '<param name="allowScriptAccess" value="always" />',
  56. '<param name="flashvars" value="' + this.getFlashVars() + '" />',
  57. '</object>'].join("");
  58. }
  59. }