Reputation: 3351
I've a java script function that is used to save a webcam Image and the code is as below.
onCapture: function () {
webcam.save("@Url.Content("~/Image/ImageCapture")/");
MatchFindFunction();
}
and in my controller the code is as below.
public void ImageCapture() //Capturing the image and save to folder
{
if (!Directory.Exists(Server.MapPath(@"~/Temp")))
{
Directory.CreateDirectory(Server.MapPath(@"~/Temp"));
}
string sessionIdValue = getSessionID();
tempPath = "~/Temp/" + sessionIdValue + ".jpg";
System.Web.HttpContext.Current.Session["tempImagePath"] = sessionIdValue;
CommonModel.path = Server.MapPath(tempPath);
CommonModel.stream = Request.InputStream;
using (CommonModel.reader = new StreamReader(CommonModel.stream))
CommonModel.dump = CommonModel.reader.ReadToEnd();
System.IO.File.WriteAllBytes(CommonModel.path, ConvertStringToByte(CommonModel.dump));
return sessionIdValue;
}
So Here my requirements is, I want to get this returned value in Javascript, I have to pass this variable to another function. I tried doing alert(webcam.save("@Url.Content("~/Image/ImageCapture")/"))
, but the message alerted here is true
, but I want the sessionIdValue in return. I'm confused, if I have to use Ajax, if so, I'm not sure of how to call this URL. As this is webcam save method.
Please let me know on how can I do this.
Thanks
Upvotes: 0
Views: 182
Reputation: 364
This @Url.Content("~/Image/ImageCapture")
is your return value. just use this instead of using webcam.save("@Url.Content("~/Image/ImageCapture")/"
in alert
function.
Upvotes: 1