上传到ftp asp.net [英] upload to ftp asp.net

查看:134
本文介绍了上传到ftp asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能直接上传文件与ASP.NET的FTP帐户​​文件夹?

Is it possible to upload a file directly into an ftp account folder with ASP.NET ?

例如。我点击浏览,选择要上传的文件,当我点击上传按钮,它应该直接将其保存到文件夹位于某个位置的另一Web服务器上的其他人等则正在使用上传服务器。

E.g. I click on browse, select a file to upload and when I click "upload" button, It should save it directly to the folder on another web server located at somewhere else other then the server that is being used to upload.

推荐答案

您可以使用 Web客户端类来存储上传文件到FTP(不保存为文件在服务器上)。事情是这样的:

You can use the WebClient class to store the uploaded file to FTP (without saving it as a file on the server). Something like this:

string name = Path.GetFileName(UploadControl.FileName);
byte[] data = UploadControl.FileBytes;

using (WebClient client = new WebClient()) {
   client.UploadData("ftp://my.ftp.server.com/myfolder/" + name, data);
}

这篇关于上传到ftp asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆