This article is Ding Ding, such as reprinting, please indicate the source: http://blog.9cbs.net/weisunding [WebMethod (Description = "Upload and Save Image 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); // is not an absolute path if (! savepath.endswith ("//")) SavePath = "//";
if {throw new Exception ( "the server does not find a valid path to save!");} (Directory.Exists (savePath)!) 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 surcess = true;} catch (Exception EX) ) {Throw new exception;} finally {filestream.close ();} returnis
Solution: Write the WebService Process Savefile (Byte [] Bindata, String FileName0; the client is directly used to pass the data stream parameters.