title: how to upload the image from iphone and using .NET webservices
body: <p>I want to upload the image using the .NET webservices and that will be called from iphone image.</p>
  
  <p>the format of text that iphone is sending to me is like this. </p>
  
  <p><a href="http://d8768157.u118.c6.ixwebhosting.com/iphoneimg/image.txt" rel="nofollow">http://d8768157.u118.c6.ixwebhosting.com/iphoneimg/image.txt</a></p>
  
  <p>In which datatype i must convert this data and then save that in image format.</p>
  
  <p>If you have any other method then please tell me.</p>
  
  <p>I have tried converting this data in the byte[] but it is giving me error. here is my code. For what i have tried. please help me out.</p>
  
  <pre><code>[WebMethod]
      public XmlDocument testuploadimage(string image)
      {
          XmlDocument login = new XmlDocument();
          XmlDeclaration dec = login.CreateXmlDeclaration("1.0", null, null);
          login.AppendChild(dec);
          XmlElement root = login.CreateElement("CreateUser");
          login.AppendChild(root);
          try
          {
  
              string actFolder = Server.MapPath("~/iphoneimg/");
              string imgname = DateTime.UtcNow.ToString().Replace(" ", "").Replace("AM", "").Replace("PM", "").Replace("/", "").Replace("-", "").Replace(":", "") + ".png";
  
              Bitmap map;
  
              using (MemoryStream stream = new MemoryStream(Convert.FromBase64String(image)))
              using (FileStream fs = File.Create(actFolder + imgname))
              {
                  map = (Bitmap)Image.FromStream(stream);
                  map.Save(fs, System.Drawing.Imaging.ImageFormat.Gif);
              }
  
              XmlElement root1 = login.CreateElement("uploaded");
              root1.InnerText = "true";
              root.AppendChild(root1);
              XmlElement root2 = login.CreateElement("path");
              root2.InnerText = "http://d8768157.u118.c6.ixwebhosting.com/iphoneimg/" + imgname;
              root.AppendChild(root2);
  
              return login;
          }
          catch (Exception ex)
          {
              throw ex;
          }
  
      }
  </code></pre>
  
  <p>this is the error i m getting</p>
  
  <p><strong>Invalid character in a Base-64 string.</strong></p>
  
  <p>Thanks</p>
  
  <p>BHAVIK GOYAL</p>