zoukankan      html  css  js  c++  java
  • 前台单击文件,jQuery删除后台相应真实的文件

     Untitled Page

        <script type="text/javascript">
            $(function() {
                $("body img").click(function() {
                    var name = $(this).attr("alt");
                    $.ajax({
                    url: "DeletePicsForm.aspx",
                        data: "picname="+name,
                        datatype: "json",
                        type: "GET",
                        contentType: "application/json; charset=utf-8",
                        success: function(data, textStatus) {
                            alert(data.result);
                        },
                        error: function(XMLHttpRequest, textStatus, errorThrown) {
                            alert(XMLHttpRequest);
                        }
                    });
                });
            });
        </script>

    DeletePicsForm.aspx.cs:

      protected void Page_Load(object sender, EventArgs e)         {      

           if (Request["picname"] != null)             {    

                 Response.Clear();             

               Response.ContentType = "application/json";     

               String result = "success";               

             try                 {          

               File.Delete(Server.MapPath(@"\Images\")+Request["picname"].ToString());       

              }             

           catch (Exception ee)                 {   

               result = ee.Message;       

              }             

            Response.Write("{\"result\":\"" +result+ "\"}");     

                Response.End();             }   

          }

  • 相关阅读:
    iOS--不重复随机数srand(time(0))
    iOS--kvo&kvc的使用
    iOS-- 添加真机测试
    iOS-- 使用xib实现自动布局
    iOS8-- Size Class的使用
    iOS--排序算法集合
    iOS--使用MD5加密
    iOS--判断一个字符串是不是手机号
    iOS--ASIHTTPRequest类库的添加和使用
    Python入门
  • 原文地址:https://www.cnblogs.com/dongbo19910728/p/2958374.html
Copyright © 2011-2022 走看看