我正在使用 ASP.Net MVC 4 和 WebImage 助手。我需要通过 FTP 上传我的 WebImage 对象。我只是不知道如何让 WebImage 参数发送到我的 RequestStream.Write
这是一些代码...
WebImage photo = WebImage.GetImageFromRequest();
string fileName = System.IO.Path.GetFileName(photo.FileName);
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(FTPaddress +"/images/" + fileName);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential("****", "*****");
request.UsePassive = true;
request.ContentLength = ???????;
byte[] buffer = ????????; //It's not photo.GetBytes;
Stream requestStream = request.GetRequestStream();
requestStream.Write(buffer, 0, request.ContentLength);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
response.Close();
之后我可以使用 photo.Save() 到 FTP 路径吗?