예제 #1
0
        /// <summary>
        /// 上传文件(没有完成,文件上传)
        /// </summary>
        public void uploadFile(HttpContext context)
        {
            string name        = null;
            string userimgName = "";

            if (context.Request.Files.Count > 0)
            {
                XiuXiuPostImage img = new XiuXiuPostImage(context);
                name        = img.Save();
                userimgName = img.FileUserName;
            }
            //   /upload/User201653198236.png
            string fileType = HttpContext.Current.Request["fileType"];//文件类型

            string[] strArr   = name.Split('/');
            string   fileName = strArr[strArr.Length - 1];
            string   filePath = name;
            string   userId   = HttpContext.Current.Session["userID"].ToString();
            sceneBll bll      = new sceneBll();
            string   id       = bll.AddFile(fileName, filePath, userId, fileType, userimgName);

            if (id != "")
            {
                string msg = @"{
                'success': true, 
                'code': 200, 
                'msg': 'success', 
                'obj': {
                    'id': '" + id + @"',
                    'name': '" + fileName + @"',
                    'extName': '" + fileName.Split('.')[1] + @"',
                    'fileType': " + fileType + @",
                    'path': '" + filePath + @"',
                    'tmbPath': '" + filePath + @"',
                    'createTime': '" + DateTime.Now.ToString() + @"',
                    'createUser': '******',
                    'bizType': 0, 
                    'sort': 0, 
                    'size': 2, 
                    'status': 1
                }, 
                'map': null, 
                'list': null}";
                context.Response.Write(MentStr(msg));
            }
            else
            {
                string msg = @"{
                    'success': false,
                    'code': 403,
                    'msg': '上传文件失败',
                    'obj': null,
                    'map': null,
                    'list': null
                }";
                context.Response.Write(msg);
            }
        }
예제 #2
0
        public void ProcessRequest(HttpContext context)
        {
            string name = null;

            if (context.Request.Files.Count > 0)
            {
                //config 配置节点可以将图片保存至指定目录,未配置将保存至 /XiuXiuUpload
                //<appSettings>
                //  <add key="XiuXiuImageSavePath" value="/upload"/>
                //</appSettings>
                XiuXiuPostImage img = new XiuXiuPostImage(context);
                name = img.Save();
            }
            else
            {
                name = "非法访问";
            }
            context.Response.ContentType = "text/plain";
            context.Response.Write(name);
        }