2011-12-09 2 views
0

내 MVC 앱에서 plupload를 구현했습니다. 그것은 잘 가고 있었지만보기에 있었다. 디렉터리 지정시 plupload 오류가 발생했습니다.

나는 그것의 자신의 파일로 이사하기로 결정 없습니다 : 그것은 plupload.flash.swf 또는 plupload.silverlight.xap 찾을 수

enter image description here

그것은 더 이상 일하고있어.

$(function() { 
    $("#dialog").dialog({ 

     autoOpen: false, 
     buttons: { 
      "OK": function() { 
       var invoiceComment = { 
        InvoiceId: invoiceId, 
        Comment: $('#comment').val() 
       }; 
       $.post('/Invoice/AddComment', invoiceComment); 
       $(this).dialog('close'); 
      } 
     } 
    }); 
    $(".btncomment").click(function() { 
     invoiceId = $(this).attr("data-invoiceid"); 
     $("#dialog").dialog('open'); 
    }); 

    var filelist = $('#filelist'); 
    var pickfiles = $('#pickfiles'); 
    var uploadfiles = $('#uploadfiles'); 

    var uploader = new plupload.Uploader({ 
     runtimes: 'flash,silverlight,html5,html4', 
     //runtimes: 'silverlight,html5, html4', 
     //runtimes: 'html5,html4', 
     //runtimes: 'html4', 
     browse_button: pickfiles.attr('id'), 
     container: 'container', 
     max_file_size: '10mb', 
     //chunk_size: '1mb', 
     multi_selection: false, 
     multipart: true, 
     urlstream_upload: true, 
     url: '@Url.Action("Upload", "Invoice")', 
     flash_swf_url: '@Url.Content("~/Scripts/plupload/js/plupload.flash.swf")', 
     silverlight_xap_url: '@Url.Content("~/Scripts/plupload/js/plupload.silverlight.xap")', 
     filters: [ 
      { title: "Image Files", extensions: "jpg,gif,png,pdf" }, 
      { title: "Zip Files", extensions: "zip" }, 
      { title: "Office Files", extensions: "doc,docx,xls,xlsx" } 
      ], 
     resize: { width: 320, height: 240, quality: 90 } 
    }); 

    uploader.bind('Init', function (up, params) { 
     showpickfiles(true); 
    }); 

    uploadfiles.click(function (e) { 
     uploader.start(); 
     e.preventDefault(); 
    }); 

    uploader.init(); 

    uploader.bind('FilesAdded', function (up, files) { 
     filelist.empty(); 

     $.each(files, function (i, file) { 
      filelist.append('<div id="' + file.id + '">' + file.name + 
       ' (' + plupload.formatSize(file.size) + ') <b></b>' + 
       '<a href="#" id="cancel' + file.id + '" class="cancel"> [Cancel]</a>'); 

      //Bind cancel click event 
      $('#cancel' + file.id).click(function() { 
       $('#' + file.id).remove(); 
       showpickfiles(true); 
       uploader.removeFile(file); 
       uploader.refresh(); 
      }); 

      showpickfiles(false); 
     }); 

     up.refresh(); // Reposition Flash/Silverlight 
    }) 

    uploader.bind('UploadProgress', function (up, file) { 
     $('#' + file.id + " b").html(file.percent + "%"); 
    }); 

    uploader.bind('Error', function (up, err) { 
     if (err.code == -600) { 
      filelist.append('<div style="color: #CC0000;">Error - File size is greater than 10MB' 
      + (err.file ? ', File: ' + err.file.name : "") + '</div>'); 
     } 
     else { 
      filelist.append('<div style="color: #CC0000;">Error - ' + err.message 
       + (err.file ? ', File: ' + err.file.name : "") + '</div>'); 
     } 

     up.refresh(); // Reposition Flash/Silverlight 
    }); 

    uploader.bind('FileUploaded', function (up, file) { 
     $('#' + file.id + " b").html("100%"); 
     $('#cancel' + file.id).remove(); 
     pickfiles.html('[Replace Invoice]'); 
     showpickfiles(true); 
     up.refresh(); 
    }); 

    var showpickfiles = function (show) { 
     if (show) { 
      pickfiles.show(); 
      uploadfiles.hide(); 
     } else { 
      pickfiles.hide(); 
      uploadfiles.show(); 
     } 
    } 
}); 

내가 잘못이 파일의 위치를 ​​지정한 다음은

는 pluploadimplementation.js의 내용입니까?

답변

0

이러한 파일의 위치를 ​​잘못 지정 했습니까?

예. 정적 자바 스크립트 파일에 @Url.Content 서버 측 도우미를 사용했습니다. 뷰 내부에서만 서버 측 구성을 사용할 수 있습니다.

는 가능성의 몇 가지가 있습니다

    이동
  • uploader 자바 스크립트의 URL 헬퍼가 작동하는지 있도록 뷰의 일부 인라인 <script> 선언 내부의 모든 설정과 경로가 포함되어 변수입니다. 다음

    <div id="uploadfiles" data-swfurl="@Url.Content("~/Scripts/plupload/js/plupload.flash.swf")" data-xapurl="@Url.Content("~/Scripts/plupload/js/plupload.silverlight.xap")">Upload</div> 
    

    과 :

    var uploadfiles = $('#uploadfiles'); 
    
    var uploader = new plupload.Uploader({ 
        runtimes: 'flash,silverlight,html5,html4', 
        //runtimes: 'silverlight,html5, html4', 
        //runtimes: 'html5,html4', 
        //runtimes: 'html4', 
        browse_button: pickfiles.attr('id'), 
        container: 'container', 
        max_file_size: '10mb', 
        //chunk_size: '1mb', 
        multi_selection: false, 
        multipart: true, 
        urlstream_upload: true, 
        url: '@Url.Action("Upload", "Invoice")', 
        flash_swf_url: uploadfiles.data('swfurl'), 
        silverlight_xap_url: uploadfiles.data('xapurl'), 
        filters: [ 
         { title: "Image Files", extensions: "jpg,gif,png,pdf" }, 
         { title: "Zip Files", extensions: "zip" }, 
         { title: "Office Files", extensions: "doc,docx,xls,xlsx" } 
         ], 
        resize: { width: 320, height: 240, quality: 90 } 
    }); 
    
  • 사용 HTML5 데이터 - *는 #uploadfiles DOM 요소의 특성