web| upload this article dingding original, such as reprint, please specify the source: http://blog.csdn.net/weisunding
[WebMethod (description= "Upload and save picture file")]
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);//Not an absolute path
if (!savepath.endswith ("\")) Savepath + = "\";
if (! Directory.Exists (Savepath)) {
throw new Exception ("The server side did not find a valid save path!") ");
}
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;
}
Solution: Write WebService Process SaveFile (byte[] bindata,string FILENAME0;
The client directly with the call, the data stream as parameters passed up on the end.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service