zoukankan      html  css  js  c++  java
  • 上传图片

    namespace JngsWeb.Web.Interface
    {
    public partial class fileupload : System.Web.UI.Page
    {
    MultipartDataInfo mdi;
    protected void Page_Load(object sender, EventArgs e)
    {

    SendResponse(Response, Dopost());
    }

    private void SendResponse(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();
    }

    private string Dopost()
    {
    JsonData jd = new JsonData();
    JsonBase.AddJsonArray("result", ref jd);
    try
    {
    mdi = new MultipartDataInfo();

    mdi.CollectFormDatas();
    string img = "";
    string FileRealName = "";
    string FileServerName = "";
    string path;
    path = "../filehtml/";
    mdi.RootPath = path;

    if (mdi.FileCount > 0)
    {

    mdi.Save();
    foreach (MyFileInfo mfi in mdi.FileCollections)
    {
    try
    {
    FileServerName = mfi.FileName;
    FileRealName = mfi.SFileName;

    Dictionary<string, string> dict = new Dictionary<string, string>();
    string parent_id = mdi.FormCollections["parent_id"];

    string img_type = mdi.FormCollections["img_type"];
    string img_title = mdi.FormCollections["img_title"];
    string normal_img = "filehtml/" + FileServerName;

    if (string.IsNullOrEmpty(img))
    {
    img = normal_img;
    }
    else {
    img = "" + img + "," + normal_img + "";
    }
    string timg = Server.MapPath(path + FileServerName);

    if (img_type == "tousu_123")
    {
    string sql = "select * from tousu_img where tousuid=" + parent_id + "";
    var dt = BaseDal.QueryDataTable(sql);
    if (dt.Rows.Count == 0)
    {
    dict.Add("attach_url", img);
    dict.Add("attach_name", img_title);
    dict.Add("tousuid", parent_id);
    JngsDal.InsertToTable("tousu_img", dict);
    jd["result"].Add("filehtml/" + FileServerName);

    }
    else {

    dict.Add("attach_url", img);

    JngsDal.UpdateTables("tousu_img", dict, "tousuid=" + parent_id);
    jd["result"].Add("filehtml/" + FileServerName);
    }

    }

    }
    catch (Exception ex)
    {
    JngsDal.RecordError("fileupload", ex.Message);
    }
    }
    }
    }

    catch (Exception ex)
    {
    JngsDal.RecordError("fileupload1", ex.Message);
    }

    return jd.ToJson();
    }
    }
    }

  • 相关阅读:
    【流量劫持】SSLStrip 终极版 —— location 瞒天过海
    【流量劫持】沉默中的狂怒 —— Cookie 大喷发
    【流量劫持】SSLStrip 的未来 —— HTTPS 前端劫持
    Web 前端攻防(2014版)
    流量劫持 —— 浮层登录框的隐患
    流量劫持能有多大危害?
    流量劫持是如何产生的?
    XSS 前端防火墙 —— 整装待发
    XSS 前端防火墙 —— 天衣无缝的防护
    XSS 前端防火墙 —— 无懈可击的钩子
  • 原文地址:https://www.cnblogs.com/guo970910/p/9820538.html
Copyright © 2011-2022 走看看