ASP.NET MVC - Upload a file with SignalR

前端 未结 3 2088
深忆病人
深忆病人 2021-01-04 09:26

I want to upload a file from the client to the server. Is there a way to upload a file with SignalR or must i need a Controller for this?

3条回答
  •  情话喂你
    2021-01-04 09:54

    This file uploading using file input bootstrap plugin (krajee) You can also upload file without using this plugin.

        @section Page{
    
        
        
        
        
        }
    

    Hub class code

        [HubName("ItemHub")]
        public class ItemHub : Hub
        {
              public void GetByteArray(IEnumerable images)
              {
                 foreach (var item in images ?? Enumerable.Empty())
                 {
                    var tokens = item.Image.Split(',');
                    if (tokens.Length > 1)
                    {
                       byte[] buffer = Convert.FromBase64String(tokens[1]);
    
                    }
                  }
              }
        }
    
        public class ImageData
        {
            public string Description { get; set; }
            public string Filename { get; set; }
            public string Image { get; set; }
        }
    

提交回复
热议问题