我爱Aspx >> Asp.Net >> 利用SOAP(Webservice)上传文件[WebMethod(Description="上传并保存图片文件")]
public bool SaveFile(byte[] binData,string fileName){
bool success=false;
string savePath=System.Configuration.ConfigurationSettings.AppSettings["UploadDirectory"];
if(savePath==null) savePath="Photo";
if(savePath.IndexOf(":\\")<0) savePath=Server.MapPath(savePath);//不是绝对路径
if(!savePath.EndsWith("\\")) savePath += "\\";
if(!Directory.Exists(savePath)){
throw new Exception("服务器端没有找到有效的保存路径!");
}
FileStream fileStream=null;
try{
fileStream=new FileStream(savePath + fileName,FileMode.Create,FileAccess.Write);
//write the file
fileStream.Write(binData,0,binData.Length);
fileStream.Flush();//clear the buffer,write the data to the hard disk
success=true;
}catch(Exception ex){
throw new Exception(ex.Message);
}finally{
fileStream.Close();
}
return success;
}
解决思路:编写WebService过程SaveFile(byte[] binData,string fileName0;
客户端直接用调用,把数据流作参数传上来就完了。
Ҷƪл˵?
用ASP编程控制在IIS建立Web站点[05-20]
web.config文件详解[05-20]
ASP.NET:Email Web Page[05-20]
在asp.net2.0中用WebPart代替Pla..[05-20]
用C#写一个Web自定义控件[05-20]
用C#写一个Web自定义控件[05-20]
Ajax: 一个建立Web应用的新途径[05-20]
设置WEB(INTERNET)打印页眉页脚为..[05-20]
C#实现WEB服务器[05-20]
实现支持断点续传多线程下载的 H..[05-20]
利用ASP.NET实现域名查询[05-20]
网页防刷新重复提交、防后退解决..[05-20]
IE经典故障大全[05-20]
用ASP的方法动态写出JavaScript的..[05-20]
JavaScript 更改网页中字体大小,..[05-20]
Javascript里的类构造[05-20]
用 JavaScript 操作字符串[05-20]
JavaScript中this关键字使用方法..[05-20]
[例程]使用VBScript 中的类组织开..[05-20]
预装载以及JavaScript Image()对..[05-20]