0

アップロード機能に FlowJS angular プラグインを使用しようとしていますが、少し調整する必要があります。すべての種類のファイルが必要です

ASP.NET MVC を使用しています。

.config(['flowFactoryProvider', function (flowFactoryProvider) {
flowFactoryProvider.defaults = {
 target: '',
 permanentErrors: [500, 501],
 maxChunkRetries: 1,
 chunkRetryInterval: 5000,
 simultaneousUploads: 1
};

私の入力ボタン

<input type="file" flow-btn />

私のアップロードボタン

  <input type="button"  ng-click="uploadFiles($flow)">

そして機能

 $scope.uploadme = function (flows) {
    flows.upload();
 });

私のmvcコントローラー

  [HttpPost]
    public string UploadFile(HttpPostedFileBase file)
    {
        int fileSizeInBytes = file.ContentLength;
        MemoryStream target = new MemoryStream();
        file.InputStream.CopyTo(target);
        byte[] data = target.ToArray();
        return "";
    }

これは正常に機能しますが、複数のファイルをアップロードすると、ファイルのたびにコントローラーがヒットします。すべてのファイルを一度にコントローラーに送信する方法を見つける必要があります。

    public string UploadFile(HttpPostedFileBase[] file)
    {
    }

これを達成する方法はありますか?

4

2 に答える 2

1

UploadFile(HttpPostedFileBase[] file)コントローラーのようなものは必要ありません。

コントローラーを作成するだけ

public string UploadFile()
{
  var httpRequest = HttpContext.Current.Request;
  //httpRequest.Files.Count -number of files
  foreach (string file in httpRequest.Files)
  {
      var postedFile = httpRequest.Files[file];
      using (var binaryReader = new BinaryReader(postedFile.InputStream))
      {
         //Your file
         string req = System.Text.Encoding.UTF8.GetString(binaryReader.ReadBytes(postedFile.ContentLength));

      }
}
}
于 2015-11-19T07:48:55.380 に答える
1

multipleに属性を追加しますinput

<input type="file" multiple="multiple" flow-btn />
于 2015-11-19T07:52:20.670 に答える