I want to upload the image using the .NET webservices and that will be called from iphone image.
the format of text that iphone is sending to me is like this.
http://d8768157.u118.c6.ixwebhosting.com/iphoneimg/image.txt
In which datatype i must convert this data and then save that in image format.
If you have any other method then please tell me.
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.
[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;
}
}
this is the error i m getting
Invalid character in a Base-64 string.
Thanks
BHAVIK GOYAL