我们如何通过asp.net中的文件上传控件将文件保存在跨服务器上? [英] How we can save the file on cross server through file upload control in asp.net?
本文介绍了我们如何通过asp.net中的文件上传控件将文件保存在跨服务器上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的所有人,
我想使用asp.net中的文件上传控件将文件保存在不同的服务器上。
如何实现这一目标?
Dear All,
I want to save the file on different server using file upload control in asp.net.
How can achieve this?
推荐答案
protected void UploadButton_Click(object sender, EventArgs e)
{
if(FileUploadControl.HasFile)
{
try
{
string filename = Path.GetFileName(FileUploadControl.FileName);
string[] paths = {"path1","path2","path3","path4"}
foreach(var path in paths)
{
FileUploadControl.SaveAs(path +"\"+ filename);
}
StatusLabel.Text = "Upload status: File uploaded!";
}
catch(Exception ex)
{
StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
}
}
}</pre>
如果您正在运行此应用程序的帐户有权访问其他服务器,您可以将文件保存在该位置。
If the account you are running this application has access to the other server, you will be able to save the file in that location.
这篇关于我们如何通过asp.net中的文件上传控件将文件保存在跨服务器上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文