我想从本地机器上传/保存web服务器上的文件 [英] I want to Upload/Save file on web serve from local machine

查看:189
本文介绍了我想从本地机器上传/保存web服务器上的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从本地计算机上传/保存Web服务器上的文件

使用ASP.NET FileUpload控件



try

{



string path = @\ipaddress\site2 \Styles \;

int nFileLen = FileUpload1.PostedFile.ContentLength;

byte [] myData = new byte [nFileLen];

HttpPostedFile myFile = FileUpload1.PostedFile ;

myFile.InputStream.Read(myData,0,nFileLen);

FileStream newFile = new FileStream(path,FileMode.Create);

//将数据写入文件



newFile.Write(myData,0,myData.Length);

//关闭文件< br $>


newFile.Close();

}

catch(exception ex)

{

}

I want to Upload/Save file on Web server from Local Machine
using ASP.NET FileUpload Control

try
{

string path = @"\ipaddress\site2\Styles\";
int nFileLen = FileUpload1.PostedFile.ContentLength;
byte[] myData = new byte[nFileLen];
HttpPostedFile myFile = FileUpload1.PostedFile;
myFile.InputStream.Read(myData, 0, nFileLen);
FileStream newFile = new FileStream(path, FileMode.Create);
// Write data to the file

newFile.Write(myData, 0, myData.Length);
// Close file

newFile.Close();
}
catch(Exception ex)
{
}

推荐答案

谷歌是你的朋友:一个简单的搜索就能很快找到你。

http://msdn.microsoft.com/en-us/library/ ms227669(VS.80)。 aspx [ ^ ]



将来,请尝试自己做至少基础研究,不要浪费你的时间或我们的时间。
Google is your friend here: a simple search would have found you this very quickly.
http://msdn.microsoft.com/en-us/library/ms227669(VS.80).aspx[^]

In future, please try to do at least basic research yourself, and not waste your time or ours.


这篇关于我想从本地机器上传/保存web服务器上的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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