Web/admin/Plupload.ashx.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Web.admin
{
/// <summary>
/// Plupload 的摘要说明
/// </summary>
public class Plupload : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string msg = string.Empty;
int chunk = Convert.ToInt32(context.Request["chunk"]); //当前分块
int chunks = Convert.ToInt32(context.Request["chunks"]);//总的分块数量
string name = context.Request["name"];
string goodscode = context.Request["goodscode"];
BLL.thumbnail bll = new BLL.thumbnail();
foreach (string upload in context.Request.Files)
{
if (upload != null && upload.Trim() != "")
{
MODEL.thumbnail model = new MODEL.thumbnail();
string path = context.Server.MapPath("~/goods/thumbnails/" + goodscode + "/");
if (!System.IO.Directory.Exists(path)) //判断给定的路径上是否存在该目录
{
System.IO.Directory.CreateDirectory(path); //不存在则创建该目录
}
System.Web.HttpPostedFileBase postedFile = new HttpPostedFileWrapper(context.Request.Files[upload]) ; //获取客户端上载文件的集合
string filename1 = System.IO.Path.GetFileName(postedFile.FileName); //获取客户端上传文件的名称及后缀
string filename = name; //
string newFileName = filename;
if (chunks > 1)
{
newFileName = chunk + "_" + filename; //按文件块重命名块文件
}
string fileNamePath = path + newFileName; //将块文件和临时文件夹路径绑定
postedFile.SaveAs(fileNamePath); //保存上载文件内容
model.thumbnailPath = "../goods/thumbnails/" + goodscode+"/" + newFileName;
if (!string.IsNullOrEmpty(goodscode) && goodscode != "null")
{
model.goodsCode = goodscode;
model.addtime = DateTime.Now;
bll.Add(model);
}
if (chunks > 1 && chunk + 1 == chunks) //判断块总数大于1 并且当前分块+1==块总数(指示是否为最后一个分块)
{
using (System.IO.FileStream fsw = new System.IO.FileStream(path + filename, System.IO.FileMode.Create, System.IO.FileAccess.Write))
{
System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fsw);
// 遍历文件合并
后面还有 25 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
