我现在FTP上传图片成功了,但是图片上传后必须在本地建立文件夹在从文件夹里面拿出图片在上传到FTP服务器,我现在想直接将上传的图片转成image对象直接上传FTP服务器,不在本地文件夹中存储了.这代码怎么做啊?public bool ftpupload_wap_img(System.Drawing.Image image, string uri)
{
FtpWebRequest reqFTP;
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri));
reqFTP.Credentials = new NetworkCredential("test", "test");
reqFTP.KeepAlive = false;
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
reqFTP.UseBinary = true; //实例化流
MemoryStream imageStream = new MemoryStream();
//将图片的实例保存到流中
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg);
//保存流的二进制数组
byte[] imageContent = new Byte[imageStream.Length]; imageStream.Position = 0;
//将流泻如数组中
imageStream.Read(imageContent, 0, (int)imageStream.Length);
byte[] buff = imageStream.ToArray();
try
{
Stream strm = reqFTP.GetRequestStream();
strm.Write(buff, 0, buff.Length);
strm.Close();
}
catch (Exception ex)
{
return false;
}
return true;
}这是我改的代码,图片上传后有此存转化的(image对象是此存转化后的对象),但是转成对应的尺寸后到FTP看不一样!
{
FtpWebRequest reqFTP;
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri));
reqFTP.Credentials = new NetworkCredential("test", "test");
reqFTP.KeepAlive = false;
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
reqFTP.UseBinary = true; //实例化流
MemoryStream imageStream = new MemoryStream();
//将图片的实例保存到流中
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg);
//保存流的二进制数组
byte[] imageContent = new Byte[imageStream.Length]; imageStream.Position = 0;
//将流泻如数组中
imageStream.Read(imageContent, 0, (int)imageStream.Length);
byte[] buff = imageStream.ToArray();
try
{
Stream strm = reqFTP.GetRequestStream();
strm.Write(buff, 0, buff.Length);
strm.Close();
}
catch (Exception ex)
{
return false;
}
return true;
}这是我改的代码,图片上传后有此存转化的(image对象是此存转化后的对象),但是转成对应的尺寸后到FTP看不一样!
论坛签名======================================================================huhailong520:你好!
截至 2011-10-21 14:47:36 前:
你已发帖 23 个, 未结贴 0 个;
结贴率为: 100.00%
当您的问题得到解答后请及时结贴.
http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
http://topic.csdn.net/u/20100428/09/BC9E0908-F250-42A6-8765-B50A82FE186A.html
http://topic.csdn.net/u/20100626/09/f35a4763-4b59-49c3-8061-d48fdbc29561.html如何给分和结贴?
http://community.csdn.net/Help/HelpCenter.htm#结帖如何给自己的回帖中也加上签名?
http://blog.csdn.net/q107770540/archive/2011/03/15/6250007.aspx