在基于Http协议的Post请求中,Content-type为application/x-www-form-urlencoded的传输只能传送非文件的数据。
如果想用Http的Post方法来上传数据及文件,需要实现Content-type为multipart/form-data类型的协议程序。
下面是参考了StackOverflow网站上的一个例子,实现了关于客户端上传文件的功能类,代码如下:
001 |
using System; |
002 |
using System.Net; |
003 |
using System.Text; |
004 |
using System.Collections.Generic; |
005 |
using System.IO; |
006 |
007 |
namespace ZDWorks.ZDClock.Cloud |
008 |
{ |
009 |
/// |
010 |
/// |
011 |
/// |
012 |
public class FileParameter |
013 |
{ |
014 |
|