日期:2014-05-17  浏览次数:21032 次

asp.net mvc上传文件取流

% using (Html.BeginForm("AutoUpLoadForQuotitGetPostFile", "ReleaseManager",FormMethod.Post,new {enctype="multipart/form-data"}))

 要给form的entype属性设为:enctype="multipart/form-data

后台方法:

//www.52mvc.com 

using (var fileStream = Request.Files[0].InputStream)
                {
                    int fileLength = (int)fileStream.Length;
                    fileStream.Position = 0;
                    byte[] fileArray = new byte[fileLength];
                    fileStream.Read(fileArray, 0, fileLength);
                }