예제 #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            string action = context.Request["action"];

            if (action == "tmpImg")
            {
                //上传配置
                string pathbase = "tmp/";                                                          //保存路径
                int size = 2;                     //文件大小限制,单位mb                                                                                   //文件大小限制,单位KB
                string[] filetype = { ".gif", ".png", ".jpg", ".jpeg", ".bmp" };                    //文件允许格式

                //上传图片
                Hashtable info = new Hashtable();
                Uploader up = new Uploader();
                info = up.upFile(context, pathbase, filetype, size); //获取上传状态

                HttpContext.Current.Response.Write("<script>parent.ue_callback('" + info["url"] + "','" + info["state"] + "')</script>");//回调函数
            }
            else
            {
                string pathbase = "upload/";                                        //保存路径
                string tmpPath = "tmp/";               //临时图片目录

                //上传图片
                Hashtable info = new Hashtable();
                Uploader up = new Uploader();
                info = up.upScrawl(context, pathbase, tmpPath, context.Request["content"]); //获取上传状态

                //向浏览器返回json数据
                HttpContext.Current.Response.Write("{'url':'" + info["url"] + "',state:'" + info["state"] + "'}");
            }
        }
예제 #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            //上传配置
            int size = 2;           //文件大小限制,单位MB                             //文件大小限制,单位MB
            string[] filetype = { ".gif", ".png", ".jpg", ".jpeg", ".bmp" };         //文件允许格式

            //上传图片
            Hashtable info = new Hashtable();
            Uploader up = new Uploader();

            string pathbase = null;
            int path = Convert.ToInt32(up.getOtherInfo(context, "dir"));
            if (path == 1)
            {
                pathbase = "upload/";

            }
            else
            {
                pathbase = "upload1/";
            }

            info = up.upFile(context, pathbase, filetype, size);                   //获取上传状态

            string title = up.getOtherInfo(context, "pictitle");                   //获取图片描述
            string oriName = up.getOtherInfo(context, "fileName");                //获取原始文件名

            HttpContext.Current.Response.Write("{'url':'" + info["url"] + "','title':'" + title + "','original':'" + oriName + "','state':'" + info["state"] + "'}");  //向浏览器返回数据json数据
        }
예제 #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            //上传配置
            String pathbase = "upload/";                                      //保存路径
            string[] filetype = { ".rar", ".doc", ".docx", ".zip", ".pdf", ".txt", ".swf", ".wmv" };    //文件允许格式
            int size = 100;   //文件大小限制,单位MB,同时在web.config里配置环境默认为100MB

            //上传文件
            Hashtable info = new Hashtable();
            Uploader up = new Uploader();
            info = up.upFile(context, pathbase, filetype, size); //获取上传状态

            context.Response.Write("{'state':'" + info["state"] + "','url':'" + info["url"] + "','fileType':'" + info["currentType"] + "','original':'" + info["originalName"] + "'}"); //向浏览器返回数据json数据
        }