0

I have record a Audio wav file using html5 and storing it using XMLHttpRequest code is like below

var xhr = new XMLHttpRequest();
xhr.open('POST', '/upload.aspx', true);
xhr.onload = function (e) {
    var result = e.target.result;
 };
xhr.send(blob);

And on upload.aspx has below code

String AudioFileName = "Audio_" + DateTime.Now.ToString("yyyyMMdd_hhss") + ".wav";
Request.SaveAs((Server.MapPath(".") + "/Audio/" + AudioFileName), false);
Session["AudioFileName"] = Convert.ToString(AudioFileName);

In my local I have Audio working but with the same code on server the Audio size is 0KB or 1 KB. if I play it then "Windows Media Player cannot play the file. The Player might not support the file type or might not support the codec that was used to compress the file."

  • what does the `.` represent in your `Server.MapPath` I have not seen it used like that before.. have you thought about using `Server.MapPath(Path.Combine` method for example `var path = Path.Combine(Server.MapPath("~/Audio/",)AudioFileName);` then call `Request.SaveAs(path)`; – MethodMan Jan 23 '15 at 21:26
  • I have Used (Server.MapPath(".") get correct path and as per my project that is correct. – Rajan Bajania Jan 23 '15 at 21:39
  • so are you telling me that per your project...that you are not allowed to think outside the box..? if it's correct..then it should work.. is that a correct statement / assumption..?? – MethodMan Jan 23 '15 at 21:47
  • Audio file is getting generated and stored at a physical location. The issue is Audio size is 0KB or 1 KB and not playable. Its the correct statement I have referred below link for that http://stackoverflow.com/questions/275781/server-mappath-server-mappath-server-mappath-server-mappath – Rajan Bajania Jan 23 '15 at 21:51
  • if it's stored at a physical location is that location static no matter what machine or environment you execute it from..? what happens when you debug the code.. perhaps doing that you may have an `epiphany` – MethodMan Jan 23 '15 at 21:53
  • I can't debug it on server – Rajan Bajania Jan 23 '15 at 21:58
  • that code is locally I am sure .. I am talking about debugging it locally and if it runs locally fine.. then add some logging where you can pinpoint the issues/errors when running remotely .. I think that `.` should be a `~` but what do I know – MethodMan Jan 23 '15 at 21:59

0 Answers0