using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
namespace SuperMap.RealEstate.HousingSecurity.APIPlugs.flashuploader
{
public class MyUpFlash
{
///
/// 实例化后,需要使用InitByCol()加载默认参数!
///
public MyUpFlash()
{
}
public void InitByCol(int colNum, int flashH, int cellW, int cellH, int padding)
{
int flashW = cellW * colNum + colNum + 1;//+colNum是为了增加列宽度,防止自动换行
Init(flashW, flashH, cellW, cellH, padding);
}
public void Init(int flashW, int flashH, int cellW, int cellH, int padding)
{
width = flashW;
height = flashH;
flashsrc = "/HousingSecurity/apiplugs/flashuploader/imageUploader.swf";
flashvars = new flashvars();
flashvars.Init(flashW, flashH, flashsrc, cellW, cellH, padding);
}
public void InitBig()
{
Init(885, 472, 220, 220, 20);
}
public void InitMid()
{
Init(485, 372, 100, 100, 15);
}
public string flashsrc { get; set; }
public string vars { get; set; }
///
/// flash的宽度
///
public int width { get; set; }
///
/// flash的高度
///
public int height { get; set; }
public flashvars flashvars { get; set; }
}
public class flashvars
{
public void Init(int flashw, int flashh, string flashurl, int cellW, int cellH, int padding)
{
container = "flashConainer";
url = "/HousingSecurity/api/upload/upimg.ashx";
ext = "{\"param1\":\"value1\", \"param2\":\"value2\"}";
fileType = "{\"description\":\"图片\", \"extension\":\"*.gif;*.jpeg;*.png;*.jpg\"}";
flashUrl = flashurl;
width = flashw - 1;//flash的宽度(ie需要减去容器边框)
height = flashh;
gridWidth = cellW + 1;
gridHeight = cellH;
picWidth = cellW - padding;
picHeight = cellH - padding;
uploadDataFieldName = "upfile";
picDescFieldName = "pictitle";
maxSize = 3;
compressSize = 0;//强制每个都压缩
maxNum = 32;
compressSide = 1;
compressLength = 800;//按宽度,限制最宽700
}
public string ToVarString()
{
//有效参考:
//container=flashContainer&url=http%3A%2F%2Flocalhost%3A8080%2FRentPlatform%2FExternalNetwork_Module%2FAticleManager%2Fueditor%2Fnet%2FimageUp.ashx&ext=%7B%22param1%22%3A%22value1%22%2C%20%22param2%22%3A%22value2%22%7D&fileType=%7B%22description%22%3A%22%E5%9B%BE%E7%89%87%22%2C%20%22extension%22%3A%22*.gif%3B*.jpeg%3B*.png%3B*.jpg%22%7D&flashUrl=imageUploader.swf&width=608&height=272&gridWidth=121&gridHeight=120&picWidth=100&picHeight=100&uploadDataFieldName=upfile&picDescFieldName=pictitle&maxSize=4&compressSize=2&maxNum=32&compressSide=0&compressLength=900
//
/*
参考:
*
string _FLASHVARS = string.Empty;
//_FLASHVARS = "container=flashContainer&url=UploadImage.ashx&ext=%7B%22param1%22%3A%22value1%22%2C%20%22param2%22%3A%22value2%22%7D&fileType=%7B%22description%22%3A%22%E5%9B%BE%E7%89%87%22%2C%20%22extension%22%3A%22*.gif%3B*.jpeg%3B*.png%3B*.jpg%22%7D&flashUrl=imageUploader.swf&width=608&height=272&gridWidth=121&gridHeight=120&picWidth=100&picHeight=100&uploadDataFieldName=upfile&picDescFieldName=pictitle&maxSize=4&compressSize=2&maxNum=32&compressSide=0&compressLength=900";
//_FLASHVARS = "container=flashcontainer&url=uploadimage.ashx&ext=%7b%22param1%22%3a%22value1%22%2c%20%22param2%22%3a%22value2%22%7d&filetype=%7b%22description%22%3a%22%e5%9b%be%e7%89%87%22%2c%20%22extension%22%3a%22*.gif%3b*.jpeg%3b*.png%3b*.jpg%22%7d&flashurl=imageuploader.swf&width=608&height=272&gridwidth=121&gridheight=120&picwidth=100&picheight=100&uploaddatafieldname=upfile&picdescfieldname=pictitle&maxsize=4&compresssize=2&maxnum=32&compressside=0&compresslength=900";
//_FLASHVARS = "container=flashContainer&url=/BaiduUE/imageUp&ext={\"param1\":\"value1\", \"param2\":\"value2\"}&fileType={\"description\":\"图片\", \"extension\":\"*.gif;*.jpeg;*.png;*.jpg\"}&flashUrl=imageUploader.swf&width=608&height=272&gridWidth=121&gridHeight=120&picWidth=100&picHeight=100&uploadDataFieldName=upfile&picDescFieldName=pictitle&maxSize=4&compressSize=2&maxNum=32&compressSide=0&compressLength=900";
_FLASHVARS = string.Empty;
_FLASHVARS += "container=flashContainer"; //flash容器id
_FLASHVARS += "&url=/api/upload/upimg/"; //上传处理页面的url地址/ajax/Uploader/imageUp.ashx
_FLASHVARS += "&ext={\"param1\":\"value1\", \"param2\":\"value2\"}"; //可向服务器提交的自定义参数列表
_FLASHVARS += "&fileType={\"description\":\"图片\", \"extension\":\"*.gif;*.jpeg;*.png;*.jpg\"}";//上传文件格式限制
_FLASHVARS += "&flashUrl=" + _FLASH_SRC; //上传用的flash组件地址
_FLASHVARS += "&width=" + (_FLASH_W - 1); //flash的宽度(ie需要减去容器边框)
_FLASHVARS += "&height=" + _FLASH_H; //flash的高度
_FLASHVARS += "&gridWidth=221"; // 每一个预览图片所占的宽度
_FLASHVARS += "&gridHeight=220";// 每一个预览图片所占的高度
_FLASHVARS += "&picWidth=200"; // 单张预览图片的宽度
_FLASHVARS += "&picHeight=200"; // 单张预览图片的高度
_FLASHVARS += "&uploadDataFieldName=upfile"; // POST请求中图片数据的key
_FLASHVARS += "&picDescFieldName=pictitle"; // POST请求中图片描述的key
_FLASHVARS += "&maxSize=4"; // 文件的最大体积,单位M
_FLASHVARS += "&compressSize=2"; // 上传前如果图片体积超过该值,会先压缩,单位M
_FLASHVARS += "&maxNum=32";// 单次最大可上传多少个文件
_FLASHVARS += "&compressSide=0";//等比压缩的基准,0为按照最长边,1为按照宽度,2为按照高度
_FLASHVARS += "&compressLength=900"; //能接受的最大边长,超过该值Flash会自动等比压缩
*/
System.Text.StringBuilder _buf = new StringBuilder();
_buf.Append("container=" + this.container);
_buf.Append("&url=" + System.Web.HttpContext.Current.Server.UrlEncode(this.url));
_buf.Append("&ext=" + System.Web.HttpContext.Current.Server.UrlEncode(this.ext));
_buf.Append("&fileType=" + System.Web.HttpContext.Current.Server.UrlEncode(this.fileType));
_buf.Append("&flashUrl=" + System.Web.HttpContext.Current.Server.UrlEncode(this.flashUrl));
_buf.Append("&width=" + this.width);
_buf.Append("&height=" + this.height);
_buf.Append("&gridWidth=" + this.gridWidth);
_buf.Append("&gridHeight=" + this.gridHeight);
_buf.Append("&picWidth=" + this.picWidth);
_buf.Append("&picHeight=" + this.picHeight);
_buf.Append("&uploadDataFieldName=" + this.uploadDataFieldName);
_buf.Append("&picDescFieldName=" + this.picDescFieldName);
_buf.Append("&maxSize=" + this.maxSize);
_buf.Append("&compressSize=" + this.compressSize);
_buf.Append("&maxNum=" + this.maxNum);
_buf.Append("&compressSide=" + this.compressSide);
_buf.Append("&compressLength=" + this.compressLength);
return _buf.ToString();
//return System.Web.HttpContext.Current.Server.UrlEncode(_buf.ToString());
}
///
/// flash容器id
///
public string container { get; set; }
///
/// 上传处理页面的url地址 /api/upload/upimg/
///
public string url { get; set; }
///
/// 可向服务器提交的自定义参数列表
///
public string ext { get; set; }
///
/// 上传文件格式限制
///
public string fileType { get; set; }
///
/// 上传用的flash组件地址
///
public string flashUrl { get; set; }
///
/// flash的宽度(ie需要减去容器边框)
///
public int width { get; set; }
///
/// flash的高度
///
public int height { get; set; }
///
/// 每一个预览图片所占的宽度
///
public int gridWidth { get; set; }
///
/// 每一个预览图片所占的高度
///
public int gridHeight { get; set; }
///
/// 单张预览图片的宽度
///
public int picWidth { get; set; }
///
/// 单张预览图片的高度
///
public int picHeight { get; set; }
///
/// POST请求中图片数据的key
///
public string uploadDataFieldName { get; set; }
///
/// POST请求中图片描述的key
///
public string picDescFieldName { get; set; }
///
/// 文件的最大体积,单位M
///
public int maxSize { get; set; }
///
/// 上传前如果图片体积超过该值,会先压缩,单位M
///
public int compressSize { get; set; }
///
/// 单次最大可上传多少个文件
///
public int maxNum { get; set; }
///
/// 等比压缩的基准,0为按照最长边,1为按照宽度,2为按照高度
///
public int compressSide { get; set; }
///
/// 能接受的最大边长,超过该值Flash会自动等比压缩
///
public int compressLength { get; set; }
}
}