日期:2014-05-17  浏览次数:20406 次

ueditor在上传文件时如何获取用户的信息,用于判定权限
最近一个项目用了ueditor 感觉还不错, 但在使用文件上传功能时,想通过获取session来获得当前用户的信息并判定是否具有上传权限,尝试了在ueditor文件上传的处理源文件uploader.cs中获取

HttpContext.Current.Session["userName"].ToString();



但获取失败了, 请教有没有遇到过类似问题的大牛,如何解决这个问题呢.
ueditor?session

------解决方案--------------------
如果是ashx,你需要继承IRequiresSessionState接口
------解决方案--------------------
这和IRequiresSessionState接口 无关。。继承了之后在FF和chrome中也是不能直接获取到session的。正在研究怎么弄。有大神有经验的请一定告之。谢谢。
------解决方案--------------------
引用:
这和IRequiresSessionState接口 无关。。继承了之后在FF和chrome中也是不能直接获取到session的。正在研究怎么弄。有大神有经验的请一定告之。谢谢。


那你为什么非得在upload.cs里判断呢?你可以在imageUp.ashx里判断啊

<%@ WebHandler Language="C#" Class="imageUp" %>

using System;
using System.Web;
using System.IO;
using System.Collections;
using System.Web.SessionState;
public class imageUp : IHttpHandler, IRequiresSessionState
{
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";

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

        string username = context.Session["userName"].ToString();
        if (!HasRight(username))
        {
          //提示没有权限
        }
        //上传图片
        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
        {
    &