c# - how to delete file in asp.net mvc using jquery -
my script
$("#btndelete").click(function () { $.post(url, { filename: _filenameattachementphoto }, function (data) { $("#resumepart4").html(data); }); });
my controllers
[httppost] public actionresult deleteconfirmed(string filename) { var path = path.combine(server.mappath("~/app_data/uploads"), filename); fileinfo file = new fileinfo(path); if (file.exists) { file.delete(); } return redirecttoaction("deleteconfirmed"); }
i tried nothing happened.
try this
$.post('@url.action("deleteconfirmed", "controllername")', { filename: filename });
Comments
Post a Comment