Share via


WSS 2.0 : How to upload images by using Imaging WebService

Here you go for the sample code.

                 try
                 {
                             //create imaging web service object
                             localhost.Imaging img = new ImagingTest.localhost.Imaging();
                             //set url
                             img.Url = https://localhost:8081/sites/site1/_vti_bin/Imaging.asmx;
                             //Set credential
                             img.Credentials = System.Net.CredentialCache.DefaultCredentials;
                             //for results
                             System.Xml.XmlDocument resdoc= new System.Xml.XmlDocument();
                             System.Xml.XmlNode resnode = resdoc.CreateNode(System.Xml.XmlNodeType.Element,"Result","");
                                                               
                            System.IO.FileStream fs = new System.IO.FileStream("c:\\n15.jpg",  System.IO.FileMode.Open, System.IO.FileAccess.Read);
                            //Get the content
                            byte[] content = new byte[fs.Length];

                            //store the content
                            fs.Read(content, 0, (int) fs.Length);
                                                
                            //Upload the file - specify "" for root folder, for sub folders specify 1, 2, 3 relative to the folder number
                            resnode = img.Upload("123", "", content, "n15.jpg", true);
                            MessageBox.Show(resnode.OuterXml);
                 }
                 catch(Exception ex)
                 {
                        MessageBox.Show(ex.ToString());
                 }