I\'m trying to post an image from an iphone app to a .Net webservice and I\'m running into this error. I\'ve already updated my web.config as per this kb article and I can
Thanks r_honey,
Some additional code
[WebMethod]
public string UploadFile()
{
//if you take parameter in UploadFile() like UploadFile(string cropName, .....), then give error System.InvalidOperationException: Request format is invalid: multipart/form-data
string ret = "";
HttpRequest request = this.Context.Request;
HttpPostedFile file = request.Files["upload"];
string FileName = file.FileName;
string cropName = request["cropName"];
string ext = Path.GetExtension(FileName).ToLower();
if (!(ext == ".png" || ext == ".jpg" || ext == ".jpeg"))// for only images file
{
ret = string.Format("File extension {0} not allowed.", ext);
return ret;
}
if (FileName != "")
{
string path = HttpRuntime.BinDirectory;
string UUID = System.Guid.NewGuid().ToString();
string filepath = path + "upload/" + UUID + ".jpg";
file.SaveAs(filepath);
// add your code if any
}
}