代码修改后的版本,全部提交
This commit is contained in:
63
Mtxfw.shop/artDialog/net/imageUp.cs
Normal file
63
Mtxfw.shop/artDialog/net/imageUp.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Web.SessionState;
|
||||
namespace Mtxfw.shop
|
||||
{
|
||||
public class imageUp : IHttpHandler, IRequiresSessionState
|
||||
{
|
||||
public void ProcessRequest(HttpContext context)
|
||||
{
|
||||
if (context.Session["MemberIdMemberId"] != null || (context.Session["MemberId"] != null && context.Session["MemberName"] != null))
|
||||
{
|
||||
if (!String.IsNullOrEmpty(context.Request.QueryString["fetch"]))
|
||||
{
|
||||
context.Response.AddHeader("Content-Type", "text/javascript;charset=utf-8");
|
||||
context.Response.Write(String.Format("updateSavePath([{0}]);", String.Join(", ", Config.ImageSavePath.Select(x => "\"" + x + "\""))));
|
||||
return;
|
||||
}
|
||||
|
||||
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 path = up.getOtherInfo(context, "dir");
|
||||
if (String.IsNullOrEmpty(path))
|
||||
{
|
||||
path = Config.ImageSavePath[0];
|
||||
|
||||
}
|
||||
else if (Config.ImageSavePath.Count(x => x == path) == 0)
|
||||
{
|
||||
context.Response.Write("{ 'state' : '非法上传目录' }");
|
||||
return;
|
||||
}
|
||||
info = up.upFile(context, path, filetype, size, (context.Session["MemberIdMemberId"] != null ? 1 : 0)); //获取上传状态
|
||||
|
||||
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数据
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReusable
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user