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

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -