if I have an audio(html5) tag like example bellow contains an audio(not empty)
how can I upload the audio content to my server using ajax. the problem is what the attribute or value of audio tag should I send by ajax to action in the controller. . html part:
<audio id="audiotag" src="http://www.sololearn.com/uploads/audio.mp3" controls>
Audio element not supported by your browser
</audio>
ajax:
$.ajax({
type: 'POST',
data: { 'recording': $('#audiotag').val() },
url: '@Url.Action("UploadAudio", "Pages")',
success: function (data) {
alert('s');
}
});
action in controller:
public async Task<IActionResult> UploadAudio(IFormFile recording)
{
string audio = await UserFile.UploadeNewFileAsync("", recording,
_environment.WebRootPath, Properties.Resources.Courses);
return Ok();
}