我正在使用asp.net和Visual Basic。
我有一个接收图像的FileUpload字段。我需要调整大小比图像和上传它到ftp服务器(一个外部的)
我有一个接收HttpPostedFile并将其转换为图像的函数:
image = System.Drawing.Image.FromStream(imagen.InputStream)
smallImage = New Drawing.Bitmap(image, New Drawing.Size("widht", "height"))我需要将"smallImage“转换为HttpPostedFile,或者了解如何将BitMap文件上传到我的外部服务器,但我不知道如何执行这两个选项。
有什么想法吗?
编辑:为了将文件上传到我的外部服务器,我需要:
Dim request As FtpWebRequest = WebRequest.Create(New Uri("myftp"; & fileName))
request.Method = WebRequestMethods.Ftp.UploadFile
request.Credentials = New NetworkCredential("user", "pass")但我还不知道该怎么继续
发布于 2013-06-13 01:43:42
考虑一下WebClient类。它有几个重载的UploadFile方法,可以简化文件上传到FTP。
发布于 2013-06-13 06:55:59
不知道转换是否可能。
我遵循上面的建议:在我的主体服务器中-Save镜像
smallImage.Save(Server.MapPath("../dir/" & nameOfImage), ImageFormat.Jpeg) 将图像从我的服务器-Upload到外部服务器
My.Computer.Network.UploadFile(Server.MapPath("../dir/" & nameOfFile), "ftpAddress" & nameOfFile, "user", "pass")从我的主体服务器-Delete镜像
它工作得很好。
https://stackoverflow.com/questions/17071734
复制相似问题