2014-02-21 1 views
1

웹 사이트에서 plupload 플래시 런타임을 사용하여 파일을 첨부 파일로 업로드하고 전자 메일로 보내고 있습니다. 웹 사이트는 chrome, IE9 및 IE11에서는 제대로 실행되지만 IE8에서는 정상적으로 실행되지 않습니다. 그리고 대부분의 사용자는 IE8을 사용할 것입니다. 나는 여러 가지 일을 시도해 왔지만 아무도 일하는 것처럼 보지 못했습니다. 누구든지 제게 어떤 해결책을 제안 할 수 있습니까?plupload 플래시 런타임이 IE8에서 작동하지 않습니다.

이것은 파일 업로드를 수행하는 자바 스크립트 코드입니다.

modules.compose = (function() { 
"use strict"; 

var config = { 
    id: '', 
    requestToken: $('meta[name="__AntiForgeryToken"]').attr('content'), 
    runtimes: 'gears,flash,silverlight,browserplus,html5', 
    maxFileSize: '200mb', 
    maxQueueSize: 10485760, 
    chunkSize: '1mb', 
    pingFrequency: 100000, 
    isUploaderOpen: false 
}, 
bindUploader = function() { 
    $("#uploader").pluploadQueue({ 
     // General settings 
     runtimes: config.runtimes, 
     url: '/upload.ashx' + '?id=' + config.id, 
     max_file_size: config.maxFileSize, 
     chunk_size: config.chunkSize, 
     unique_names: false, 
     headers: { '__AntiForgeryToken': config.requestToken }, 

     // Browse filters 
     filters: [ 
      { title: "All files", extensions: "*.*" }, 
      { title: "Image files", extensions: "jpg,gif,png,tiff" }, 
      { title: "XML files", extensions: "xml" }, 
      { title: "PDF documents", extensions: "pdf" }, 
      { title: "Zip files", extensions: "zip" }, 
      { title: "Text files", extensions: "txt,log" }, 
      { title: "Powerpoint documents", extensions: "ppt,pptx,pptm,potx,potm,ppam,ppsx,ppsm,sldx,sldm,thmx" }, 
      { title: "Excel documents", extensions: "xls,xlsx,xlsm,xltx,xltm,xlsb,xlam" }, 
      { title: "Word documents", extensions: "doc,docx,docm,dotx,dotm" },     
     ], 
     preinit: { 
      Init: function (up, info) { 
       $('.plupload_header, .plupload_start').remove(); 
      } 
     }, 
     init: { 
      UploadProgress: function (up, file) { 
       bumpProgress(up, file); 
      }, 
      StateChanged: function (up) { 
       if (up.total && up.files && up.total.uploaded === up.files.length) { 
        var parent = $('#upload-status').parent(); 
        $('#upload-status').fadeOut('slow').remove(); 
        $('#send-status').appendTo(parent).fadeIn('slow'); 

        __doPostBack('ctl00$Content$btnSendMessage', ''); 
       } 
      }, 
      FilesAdded: function (up, files) { 
       var i = 0; 
       while (i++ < up.files.length) { 
        $('#btnSendMessage').removeAttr("disabled"); 
        var ii = i; 
        while (ii < up.files.length) { 
         if (up.files[i - 1].name == up.files[ii].name) { 
          up.removeFile(up.files[ii]); 
         } else { 
          ii++; 
         } 
        } 
       } 
      }, 
      QueueChanged: function (up) { 
       if (up.total.size > config.maxQueueSize) { 
        $('#upload-warning-modal').modal('show'); 

        if (up.total.queued - 1 >= 0) { 
         up.removeFile(up.files[up.total.queued - 1]); 
        } 
       } 
      } 
     }, 

     // Flash settings 
     flash_swf_url: '/assets/js/plupload/plupload.flash.swf', 

     // Silverlight settings 
     silverlight_xap_url: '/assets/js/plupload/plupload.silverlight.xap' 
    }); 
}, 
bindAddAttachments = function() { 
    $('#btnAddAttachments').click(function (e) { 
     e.preventDefault(); 

     if (!config.isUploaderOpen) { 
      bindUploader(); 
      $('#uploader').show(); 

      config.isUploaderOpen = true; 
     } 

     $(this).attr('disabled', 'disabled'); 
    }); 
}, 
bindSendMessage = function() { 
    $('#btnSendMessage').click(function (e) { 
     e.preventDefault(); 

     if (!Page_ClientValidate()) { 
      return; 
     } 

     $('.plupload_filelist_footer').css('display', 'none'); 

     $('#uploader').block({ 
      message: $('#upload-status'), 
      css: { 
       padding: 0, 
       margin: 0, 
       width: '50%', 
       top: '50%', 
       left: '35%', 
       textAlign: 'left', 
       color: '#000', 
       border: '0', 
       backgroundColor: 'transparent', 
       cursor: 'wait' 
      } 
     }); 

     $('input[type="text"], textarea').prop('readonly', true).addClass('disabled'); 

     $('#btnSendMessage').button('loading'); 

     var queue = $("#uploader").pluploadQueue(); 

     if (queue) { 
      queue.start(); 
     } else { 
      __doPostBack('ctl00$Content$btnSendMessage', ''); 
     } 
    }); 
}, 
bumpProgress = function (up, file) { 
    if (up.total.percent >= 80) { 
     $('#upload-status .progress').removeClass('progress-info').addClass('progress-success'); 
    } 

    $('#upload-status .progress .bar').css('width', up.total.percent + '%'); 
}, 
bindTextareaLimit = function() { 
    $('#txtMessage').limit('2000', '#charsLeft'); 
}, 
initAttachmentsButton = function() { 
    $('#btnAddAttachments').prop('disabled', ''); 
}, 
initPing = function() { 
    (function ping() { 
     $.get("/ping.ashx"); 
     setTimeout(ping, config.pingFrequency); 
    })(); 
}; 

return { 
    init: function (options) { 
     config = $.extend({}, config, options || {}); 

     $(function() { 
      initAttachmentsButton(); 
      initPing(); 
      bindSendMessage(); 
      bindAddAttachments(); 
      bindTextareaLimit(); 
     }); 
    }, 
    validateRecipientEmail: function (sender, args) { 
     var proxy = new ServiceProxy('/Default.aspx/', { async: false }); 

     proxy.invoke(
     'IsValidRecipient', 
     { recipient: $('#txtRecipient').val() }, 
     function (result) { 
      return (args.IsValid = result.d); 
     }); 
    }, 
    validateSenderEmail: function (sender, args) { 
     var proxy = new ServiceProxy('/Default.aspx/', { async: false }); 

     proxy.invoke(
     'IsValidSender', 
     { sender: $('#txtSender').val() }, 
     function (result) { 
      return (args.IsValid = result.d); 
     }); 
    } 
}; 
}()); 

답변

0

희망 너무 늦지 않았습니다. 최근에 같은 문제가있었습니다. 문제는 당신이 headers: { '__AntiForgeryToken': config.requestToken },
를 사용하지만 사양으로는 HTML4 런타임에서 지원되지 않습니다 :

http://www.plupload.com/docs/Options#runtimes

헤더 각 업로드 요청과 함께 사용자 지정 HTTP 헤더를 전달하는 방법. 이 옵션은 헤더 이름과 그 값의 키/값 쌍의 간단한 세트입니다.

html4 런타임에서 지원되지 않습니다. 플래시 및 실버 라이트 런 타임의 경우 특수 작동 모드가 필요합니다.

IE8에서는 파일 업로드에 다른 모든 방법을 사용할 수 없으므로 HTML4 runtime을 사용합니다. antiForgery 토큰을 설정하는 방법은 없습니다. 따라서 server-side은 antiForgery 토큰이없고 Forbidden HTTP 상태가있는 드롭으로 인해 보낸 파일이 안전하지 않다고 생각합니다.

결론 - ASP.NET MVC에서 IE8의 plupload와 함께 AntiForgery 토큰을 사용하는 방법에 대해 아끼지 않습니다.