开发者

POST file - not from client machine, from web/ftp server

I'm using .Net.

Is it possible for a开发者_C百科 web form to upload an image from a web or FTP server? The files I need to submit are on the web. If this is possible, code snippet is appreciated.


Yes, it is possible.

You can use the WebClient class to interact with other web servers in .Net server-side code.

For example:

using(var client = new WebClient())
    client.UploadFile("ftp://server/path", @"C:\path\to\file");

If the file is on a different website, you can write the following:

using(var client = new WebClient())
     client.UploadData("ftp://server/path", client.DownloadData("http://server/path"));

You can read and write FTP, HTTP, and HTTPS urls interchangeably.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜