如何从IHttpHandler

时间:2018-01-30 10:50:06

标签: c# ihttphandler



function uploadFile(Data, data) {


  $.ajax({
    url: "AdminUploadHandler.ashx?Type=" + Data,
    type: "POST",
    data: data,
    contentType: false,
    processData: false,
    dataType: "text",
    success: function(result) {

      alert(result);

    },
    error: function(err) {

      showErrMsg("Error In fileUpload.", "alert-danger", 0);

    }
  });
}




public void ProcessRequest(HttpContext context)
    {
        try
        {
            if (context.Request.Files.Count > 0)
            {
                HttpFileCollection files = context.Request.Files;
                string fileName = VirtualPathUtility.GetDirectory(context.Request.Url.LocalPath);
                context.Response.Write("0");
            }
            else
            {
                context.Response.Write("3");
            }

            context.Response.ContentType = "application/json; charset=utf-8";
        }
        catch (Exception ex)
        {
            ExceptionLogging c = new ExceptionLogging("Admin  Upload Failed", ex);
            c.ErrorLog(HttpContext.Current.ApplicationInstance.Server.MapPath("~/Logs/"));

        }
    }

我正在使用ihttphandler 我想要上传文件的物理路径,例如D:\ upload我能从HttpFileCollection文件中获取文件名但不能获取文件路径的方法 任何帮助将不胜感激

0 个答案:

没有答案