The Save action is not called because jscam_canvas_only.swf contains only "callback" . For the full API (therefore for the "save" mode) you need to download and use jscam.swf .
So, change your webcam setting to:
$("#camera").webcam({ //... swffile: "@Url.Content("~/Scripts/WebCam/jscam.swf")", //... });
Now the Save action will be called, but the file parameter will always be zero, because jscam.swf will send the image data as a hexadecimal string in the request body.
The model binding framework does not handle this by default, so you need to write additional code:
if (Request.InputStream.Length > 0) { string pic = System.IO.Path.GetFileName("capture.jpg"); string path = System.IO.Path.Combine(Server.MapPath("~/Captures"), pic); using (var reader = new StreamReader(Request.InputStream)) { System.IO.File.WriteAllBytes(path, StringToByteArray(reader.ReadToEnd())); } return Json(true, JsonRequestBehavior.AllowGet); }
You need to remove the file parameter and access the raw data from Request.InputStream , but since it is a hexadecimal string, you need to convert it to byte[] before saving it.
There is no built-in conversion in .NET, but SO is full of good solutions:
How to convert byte array to hexadecimal string and vice versa?
In my example, I used this method :
public static byte[] StringToByteArray(String hex) { int NumberChars = hex.Length/2; byte[] bytes = new byte[NumberChars]; using (var sr = new StringReader(hex)) { for (int i = 0; i < NumberChars; i++) bytes[i] = Convert.ToByte(new string(new char[2]{(char)sr.Read(), (char)sr.Read()}), 16); } return bytes; }