2011-12-09 8 views
0

MVCアプリケーションでpluploadを実装しました。それはうまくいっていたが、視野に入っていた。ディレクトリを指定するとpluploadエラーが発生する

私は、それ自身のファイルにそれを移動することを決めていない:それはplupload.flash.swfまたはplupload.silverlight.xapを見つけることができないとしてそれはもはや働いて

enter image description here

。ここで

はpluploadimplementation.jsの内容は次のとおりです。

$(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(); 
     } 
    } 
}); 

は私が間違ってこれらのファイルの場所を指定したことがありますか?

答えて

0

これらのファイルの場所を間違って指定しましたか?

はい、あります。静的なjavascriptファイルの中で@Url.Contentサーバーサイドヘルパーを使用しています。サーバー側の構成は、ビューの内部でのみ使用できます。

は可能性のカップルがあります:

    移動
  • uploader javascriptの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要素の属性

  • 関連する問題