Here's my method
[AcceptVerbs(HttpVerbs.Post)]
public void SaveImage(FormCollection formValues)
{
byte[] contents = Convert.FromBase64String(Request.Form["file"]);
System.IO.File.WriteAllBytes(Server.MapPath(Request.Form["name"]), contents);
}
It is getting posted to from this actionscript method:
public function encodeAndSave(e:MouseEvent = null):void
{
var date:Date = new Date();
var by:ByteArray = PNGEnc.encode(canvas.main_bdata);
var req:URLRequest = new URLRequest(server_path+"Home/SaveImage");
var params:URLVariables = new URLVariables();
params.file = Base64.encodeByteArray(by);
params.name = "MyImage.png";
req.method = URLRequestMethod.POST;
req.data = params;
var ldr:URLLoader = new URLLoader(req);
ldr.addEventListener(Event.COMPLETE, complete);
ldr.load(req);
function complete(e:Event):void
{
navigateToURL(new URLRequest("?" + Math.random()), "_self");
}
}
But when the encodeAndSave method runs, no file gets saved to the server...
Does anyone know how to tell if the SaveImage method has even ran? Also, when I type: http://www.mysite.com/Home/SaveImage into the address bar it says "The resource cannot be found".
Anyone have any ideas as to why it would be doing this or what i can do to try to figure it out?
If you need any more information please let me know and I'll update my question.
Thanks,
Matt