zoukankan      html  css  js  c++  java
  • eWebeditor编辑器上传图片的设置程序

    protected void Button1_Click(object sender, EventArgs e)
    {
    if (this.uploadfile.PostedFile.FileName.Equals(""))
    {
    return;
    }
    else
    {
    string _flag = Request["flag"];
    string _regex = "";

    switch (_flag)
    {
    case "img":
    _regex = @"^.+.(jpe?g|gif)$";
    break;
    case "flash":
    _regex = @"^.+.(swf)$";
    break;
    case "media":
    _regex = @"^.+.(wmv|avi|rmvb|mpeg|mov)$";
    break;
    case "file":
    _regex = @"^.+.(rar|zip|doc|pdf|txt)$";
    break;
    default:
    _regex = @"^.+.(jpe?g|gif|swf|wmv|avi|rmvb|mpeg|mov|rar|zip|doc|pdf|txt)$";
    break;
    }

    Regex test = new Regex(_regex);

    if (test.IsMatch(uploadfile.PostedFile.FileName) == true)
    {
    ClientScriptManager cs = Page.ClientScript;

    string imagesfolder = ConfigurationManager.AppSettings["imagesfolder"].ToString();
    string filename = Common.UpLoadFile(uploadfile, imagesfolder);
    string apurl = Request.Url.ToString();
    string apurl2 = Request.CurrentExecutionFilePath;
    string tempurl = apurl.Substring(0, apurl.IndexOf(apurl2));
    string appurl = Request.ApplicationPath;
    string hurl;
    if (appurl.Length == 1)
    hurl = appurl + filename.Replace("~/", "");
    else
    hurl = "/" + filename.Replace("~/", "");
    hurl = hurl.Replace("路径1", "路径2");
    string imgpreview = tempurl + hurl;
    imgpreview = imgpreview.Replace("路径1", "路径2");

    cs.RegisterClientScriptBlock(this.GetType(), "tt", "parent.document.all('divProcessing').style.display='none';parent.document.all('d_width').value='550';parent.document.all('d_height').value='341';parent.document.all('imgPreview').src='" + imgpreview + "';parent.document.all('Hurl').value='" + hurl + "';parent.document.all('d_fromurl').value='';", true);

    lblinfo.Text = "文件上传成功!<a href="">重新上传</a>";
    }
    else
    {
    lblinfo.Text = "您上传的文件类型不正确!<a href="">重新上传</a><script>parent.document.all('divProcessing').style.display='none';</script>";
    }
    }
    }

  • 相关阅读:
    adodb.stream文件操作类详解
    Html中Label标记的作用和使用介绍
    正则表达式的威力轻松消除HTML代码
    只需一行代码就能让IE 6崩溃
    码农干货系列【17】Wind.js与Promise.js
    码农干货系列【3】割绳子(cut the rope)制作点滴:旋转(rotation)
    HTML5 Canvas开发者和读者的福音
    码农干货系列【8】世界上最简单的3D渲染(no webgl)
    码农干货系列【18】getting started with Promise.js(总)
    ProgressForm
  • 原文地址:https://www.cnblogs.com/candyzhmm/p/4783426.html
Copyright © 2011-2022 走看看