这是我用来上传图片到我的 FTP 服务器的代码:
FileInfo name = new(item.ImagePath);
string uploadUrl = String.Format("{0}/{1}", "server", name.Name);
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(uploadUrl);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential("login", "password");
request.Proxy = null;
request.KeepAlive = true;
request.UseBinary = true;
request.Method = WebRequestMethods.Ftp.UploadFile;
byte[] fileContents = File.ReadAllBytes(item.ImagePath);
request.ContentLength = fileContents.Length;
Stream requestStream = request.GetRequestStream();
requestStream.WriteAsync(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
MessageBox.Show($"Upload File Complete, status {0} {response.StatusDescription}");
当我上传图片时,它说“上传文件完成,状态 0 266”,但我的服务器上什至没有创建图片。有人可以帮忙吗?
我正在尝试将图像从我的电脑上传到我的服务器