public JsonResult Test2(HttpFile[] files)
		{
			var list = (from f in files
			 select new { name = f.FileName, length = f.ContentLength }).ToList();

			return new JsonResult(list);
		}
		public object Test1(HttpFile a, HttpFile b, int c, int d)
		{
			var result = new {
				file1 = new { name = a.FileName, lenght = a.FileBody.Length },
				file2 = new { name = b.FileName, lenght = b.FileBody.Length },
				sum = c + d + a.ContentLength + b.ContentLength
			};

			return result;
		}
예제 #3
0
		internal static HttpFile[] GetFilesFromHttpRequest(HttpContext context, ParameterInfo p)
		{
			HttpFile[] files = new HttpFile[context.Request.Files.Count];

			for( int i = 0; i < context.Request.Files.Count; i++ ) {
				HttpPostedFile file = context.Request.Files[i];

				files[i] = CreateHttpFileFromHttpPostedFile(file);
			}

			return files;
		}
예제 #4
0
		private static HttpFile CreateHttpFileFromHttpPostedFile(HttpPostedFile file)
		{
			HttpFile result = new HttpFile();
			result.ContentLength = file.ContentLength;
			result.ContentType = file.ContentType;
			result.FileName = file.FileName;

			if( file.ContentLength > 0 ) {
				result.FileBody = new byte[file.ContentLength];		// 如果文件很大,可能会出问题!
				file.InputStream.Read(result.FileBody, 0, file.ContentLength);
			}
			
			return result;
		}
		public string Test1(HttpFile file1, string abc)
		{
			return string.Format("Name: {0}; Length: {1}\r\nabc: {2}", 
						file1.FileName, file1.ContentLength, abc);
		}