国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

利用SOAP(Webservice)上傳文件

2024-07-21 02:21:18
字體:
來源:轉載
供稿:網友
本文系鼎鼎原創,如轉載,請注明出處:http://blog.csdn.net/weisunding

[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;
客戶端直接用調用,把數據流作參數傳上來就完了。



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 苏尼特右旗| 临邑县| 郓城县| 福鼎市| 康保县| 南陵县| 大荔县| 酉阳| 平罗县| 龙游县| 宁阳县| 奉贤区| 云龙县| 雷山县| 甘谷县| 平舆县| 克拉玛依市| 合肥市| 咸阳市| 金寨县| 兰州市| 南通市| 定结县| 安乡县| 贡嘎县| 太原市| 嵊州市| 台前县| 鹤峰县| 南召县| 象州县| 弋阳县| 富锦市| 屏边| 红河县| 睢宁县| 密山市| 崇义县| 公安县| 连江县| 湖口县|