zoukankan      html  css  js  c++  java
  • 上传文档

    namespace JngsWeb.Web.Interface
    {
    public partial class postnotifyfile : System.Web.UI.Page
    {
    MultipartDataInfo mdi;
    protected void Page_Load(object sender, EventArgs e)
    {
    if (this.Request.HttpMethod.Equals("POST"))
    {
    SendResponse(Response, Dopost());
    }
    }
    private string Dopost()
    {
    JsonData jd = new JsonData();
    JsonBase.AddJsonProperty("result", ref jd);
    try
    {
    if (this.Request.HttpMethod.Equals("POST"))
    {
    string task_id, attach_name, attach_url;
    string img = "";
    //DbHelperSQL.RecordError("postnotifyfile", "ttt");

    mdi = new MultipartDataInfo();
    mdi.CollectFormDatas();

    Dictionary<string, string> dc = new Dictionary<string, string>();
    //string parent_id = mdi.FormCollections["parent_id"].ToString();
    task_id = mdi.FormCollections["notify_id"].ToString();
    //dc.Add("tousuid", task_id);

    if (mdi.FileCount > 0)
    {
    mdi.Save();
    //string att = Request.Url.AbsoluteUri.Replace(Request.Url.AbsolutePath, "");
    //string local_attach_name = mdi.FileCollections["image"].FileName;
    //attach_name = mdi.FormCollections["attach_name"].ToString();
    //attach_url = att + Request.ApplicationPath + "/filehtml/" + local_attach_name;
    // dc.Add("attach_name", attach_name);

    // dc.Add("attach_url1", attach_url);

    foreach (MyFileInfo mfi in mdi.FileCollections)
    {
    string att = Request.Url.AbsoluteUri.Replace(Request.Url.AbsolutePath, "");
    string local_attach_name = mdi.FileCollections["image"].FileName;
    attach_name = mdi.FormCollections["attach_name"].ToString();
    attach_url = att + Request.ApplicationPath + "/filehtml/" + local_attach_name;
    if (string.IsNullOrEmpty(img))
    {
    img = attach_url;
    }
    else
    {
    img = "" + img + "," + attach_url + "";
    }
    string sql = "select * from officeurl1 where tousuid=" + task_id + "";
    var dt = BaseDal.QueryDataTable(sql);
    if (dt.Rows.Count == 0)
    {
    dc.Add("tousuid", task_id);
    dc.Add("attach_name", attach_name);

    dc.Add("attach_url1", img);

    int lastid = BaseDal.InsertToTable("officeurl1", dc);
    JsonData js = new JsonData();
    JsonBase.AddKeyValueToJsonObject("id", lastid.ToString(), ref js);
    jd["result"] = js;
    }
    else
    {
    dc.Add("attach_url1", img);
    int lastid = BaseDal.UpdateTables("officeurl1", dc, "tousuid=" + task_id);
    JsonData js = new JsonData();
    JsonBase.AddKeyValueToJsonObject("id", lastid.ToString(), ref js);
    jd["result"] = js;

    }

    }

    }
    //int itemid =
    //int lastid = BaseDal.InsertToTable("officeurl1", dc);
    //JsonData js = new JsonData();
    //JsonBase.AddKeyValueToJsonObject("id", lastid.ToString(), ref js);
    //jd["result"] = js;
    }

    return jd.ToJson();
    }
    catch (Exception ex)
    {
    DbHelperSQL.RecordError(ex.GetType().ToString(), ex.Message);
    jd["result"] = new JsonData("{"id":"0"}");
    return jd.ToJson();
    }
    }
    public void SendResponse(System.Web.HttpResponse response, string data)
    {
    response.Clear();
    response.Cache.SetCacheability(HttpCacheability.NoCache);
    response.Buffer = true;
    response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
    response.Cache.SetExpires(DateTime.Now.AddDays(-1));
    response.Expires = 0;
    response.CacheControl = "no-cache";
    response.Cache.SetNoStore();
    response.Write(data);
    response.Flush();
    response.End();
    }
    public string randomfilename(string ext)
    {
    string tmp = Guid.NewGuid().ToString() + ext;
    return tmp;
    }
    }
    }

  • 相关阅读:
    JVM Ecosystem Report 2020
    TiDB 简介
    Docker镜像分层打包方案
    Promethues + Grafana + AlertManager使用总结
    Spring Boot自动注入原理
    Spring Boot 2.x 自定义Endpoint
    Oracle 等待事件 Enq: CF
    1000行MySQL学习笔记
    PostgreSQL DBA常用SQL查询语句
    MongoDB DBA常用的NoSQL语句
  • 原文地址:https://www.cnblogs.com/guo970910/p/9820542.html
Copyright © 2011-2022 走看看