【发布时间】:2013-03-20 02:25:31
【问题描述】:
我想在 Phonegap 应用程序中捕获图像,然后使用 $ 发送。 ajax 方法将其发送到具有 Web 服务的远程服务器。净。
我不能使用“上传”方法发送到服务器,因为它不接受 uri .asmx 我需要一个方法 $.阿贾克斯帖子。 我使用网络服务:
[WebMethod]
public bool SavePhoto(Guid IdPrestation, Guid IdPhoto, byte[] ImgIn)
{
System.IO.MemoryStream ms = new System.IO.MemoryStream(ImgIn);
System.Drawing.Bitmap b =(System.Drawing.Bitmap)System.Drawing.Image.FromStream(ms);
//Si le repertoire n'existe pas alors on le crée
// if (! RepertoirePhotoExist(IdPrestation))
//{
System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath("Photos/" + IdPrestation.ToString()));
//}
string strFichier = HttpContext.Current.Server.MapPath("Photos/" + IdPrestation.ToString() + "/" + IdPhoto.ToString() + ".jpg");
// Si le fichier existe alors
if (System.IO.File.Exists(strFichier))
{
System.IO.File.Delete(strFichier);
}
else
{
b.Save(strFichier, System.Drawing.Imaging.ImageFormat.Jpeg);
}
return true;
}
【问题讨论】:
-
你试过什么?你的代码在哪里?
-
@user2174280 如果您认为答案正确且有用,您应该接受它。