ASP.Net MVC - Read File from HttpPostedFileBase without save

后端 未结 4 1407
醉酒成梦
醉酒成梦 2020-11-29 23:40

I am uploading the file by using file upload option. And i am directly send this file from View to Controller in POST method like,

    [HttpPost]
    public          


        
4条回答
  •  余生分开走
    2020-11-30 00:10

    byte[] data; using(Stream inputStream=file.InputStream) { MemoryStream memoryStream = inputStream as MemoryStream; if (memoryStream == null) { memoryStream = new MemoryStream(); inputStream.CopyTo(memoryStream); } data = memoryStream.ToArray(); }

提交回复
热议问题