uploadify.swf需要是支持中文

  $(function () {
  //获取所有上传按钮id
  $("div[id^='fileInput_']").each(function () {
  var name = $(this).attr("id");
  create(name);
  });
  });
   
  function create(name) {
  var select = "上传图片";
  if (name.indexOf("_") > -1) {
  if (name.substring(name.lastIndexOf("_") + 1) == "1") {
  var select = "大图";
  }
  else if (name.substring(name.lastIndexOf("_") + 1) == "2") {
  select = "小图";
  }
  }
  $('#' + name).uploadify({
  'uploader': '/uploadify/uploadify.swf',
  'script': 'Pro_Sub.aspx?upfile=1',
  'cancelImg': '/uploadify/cancel.png',
  'folder': '/ProductImg/',
  'fileExt': '*.jpg;*.gif;*.png;*.bmp;*.JPEG;',
  'fileDesc': '请选择 *.jpg;*.gif;*.png,*.bmp;*.JPEG 格式的图片',
  'multi': true,
  'auto': true,
  'buttonText':select,
  'onComplete': function (event, queueId, fileObj, response, data) {
  var re = response.split('|@|');
  if (re[0] == "1") {
  var box = name.substring(10);
  var html = "<div class='ImgHtml' OnClick='change(this)'><input class='input2' style='display: none;' type='button' value='删&nbsp&nbsp&nbsp除' onclick='delImg(this);showfi("+name.replace("_",".")+");' /><input type='checkbox' checked='checked' class='hide' value='" + re[1] + "' /><img class='Img' src='" + re[1] + "'></div>";
  if (box == "1_0") {
  $("#ContentPlaceHolder1_rpAttribute_txtvalue_4").val(re[1]);
  html = "<div class='ImgHtml' OnClick='change(this)'><input class='input2' style='display: none;' type='button' value='删&nbsp&nbsp&nbsp除' onclick='delImg(this);showfi(1)' /><input type='checkbox' class='hide' value='" + re[1] + "' /><img class='Img' src='" + re[1] + "'></div>";
  $("#file0").hide();
  }
   
  $(".box" + box).append(html);
   
  } else {
  ymPrompt.errorInfo({ message: "上传失败!", showMask: true });
  }
  }
  });
  }
   
 

</script>

=============================================================================

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;

using System.Web.SessionState;
using UI;

namespace Admin.TkAdmin.Product
{
/// <summary>
/// imgsave 的摘要说明
/// </summary>
public class imgsave : IHttpHandler,IReadOnlySessionState
{
public HttpRequest Request;
public HttpResponse Response;
public HttpSessionState Session;
public void ProcessRequest(HttpContext context)
{

context.Response.ContentType = "text/plain";
Response = context.Response;
Request = context.Request;
Session = context.Session;

string upfile = Request["upfile"];
if (upfile != "")
{
//如果值为1zhi
if (upfile == "1")
{
uploadfile();
}
}

}

//对上传的图片进行保存到指定文件中
private void uploadfile()
{
HttpPostedFile file = Request.Files["Filedata"];
string UploadFile = "";
HttpContext.Current.Server.MapPath(@Request["folder"]);
string newFileName = "";
if (file != null)
{
Isfile(UploadFile);
try {
//创建随机种子
Random ra;
if (Session["IntIndexImg"] != null)
{
ra = new Random(Convert.ToInt32(Session["IntIndexImg"]));
}
else
{
ra = new Random();
}

int rInt = ra.Next(1000);

Session["IntIndexImg"] = rInt;

newFileName = DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + rInt + Path.GetExtension(file.FileName).ToUpper();
string BigimageURL = (FileUrl.ProductBigImgUrl + newFileName).Replace('\\', '/');
Isfile(FileUrl.ProductBigImgUrl);
file.SaveAs(BigimageURL);
//保存缩列图
string SmallimgeURL = (FileUrl.ProductSmallImgUrl + newFileName).Replace('\\', '/');
Isfile(FileUrl.ProductSmallImgUrl);
CreateSmallPic.CreateImageOutput(120, 60, BigimageURL, SmallimgeURL);
Response.Write("1|@|" + FileUrl.ProductSmallImgUrl1 + newFileName);

}catch
{
Response.Write("0");
}
}
}

//用于创建目录
private void Isfile(string UploadFile)
{
if (!Directory.Exists(UploadFile))
{
Directory.CreateDirectory(UploadFile);
}

}

public bool IsReusable
{
get
{
return false;
}
}
}
}

uploadfile图片上传和ashx的更多相关文章

  1. thinkphp达到UploadFile.class.php图片上传功能

    片上传在站点里是非经常常使用的功能.ThinkPHP里也有自带的图片上传类(UploadFile.class.php) 和图片模型类(Image.class.php).方便于我们去实现图片上传功能,以 ...

  2. CKEditor不借助CKFinder实现图片上传(.net版 ashx实现)

    参考博客:http://blog.csdn.net/mydwr/article/details/8669594 本人版本:4.4.6 打开文件:ckeditor/plugins/image/dialo ...

  3. ashx 图片上传路径URL

    ashx 图片上传   为了方便多出调用图片上传方法       首先我们将图片上传方法抽离出来 创建ashx 一个新的方法 using System; using System.Collection ...

  4. ashx 图片上传

    为了方便多出调用图片上传方法       首先我们将图片上传方法抽离出来 创建ashx 一个新的方法 using System; using System.Collections.Generic; u ...

  5. ajax图片上传(asp.net +jquery+ashx)

    一.建立Default.aspx页面 <%@ Page Language="C#" AutoEventWireup="true"  CodeFile=&q ...

  6. plupload简易应用 多图片上传显示预览以及删除

    <script> var uploader = new plupload.Uploader({ //实例化一个plupload上传对象 browse_button: 'btnBrowse' ...

  7. ASP.NET工作笔记之一:图片上传预览及无刷新上传

    转自:http://www.cnblogs.com/sibiyellow/archive/2012/04/27/jqueryformjs.html 最近项目里面涉及到无刷新上传图片的功能,其实也就是上 ...

  8. ASP.NET图片上传和截取

    一.介绍:图片的上传直接使用ajax就可以了,截取图片的话使用到Jcrop插件. 图片上传资料:https://www.jb51.net/article/87654.htm 截取图片插件:http:/ ...

  9. 对百度的UEditor多图片上传的一些补充

    我已经写了一篇文章关于百度的UEditor提取多图片上传模块.如果还没有看过,请点击以下链接查看 http://www.cnblogs.com/luke1006/p/3719029.html 出差了两 ...

随机推荐

  1. Wireshark抓包工具

    首先下载并安装Wireshark软件,最好选择中文版,因为会使你用的更顺手. 安装完毕之后,双击打开Wireshark软件,主界面还是比较清晰明了的,可是怎么用还是稀里糊涂的吧. 点击菜单栏红圈中的选 ...

  2. highcharts的表名

    line:直线图 spline:曲线图 area:面积图 areaspline:曲线面积图 arearange:面积范围图 areasplinerange:曲线面积范围图 column:柱状图 col ...

  3. Spring PropertyPlaceholderConfigurer数据库配置

    pom.xml中添加依赖 <!-- mysql-connector-java --> <dependency> <groupId>mysql</groupId ...

  4. 史上最简单,一步集成侧滑(删除)菜单,高仿QQ、IOS。

    重要的话 开头说,not for the RecyclerView or ListView, for the Any ViewGroup. 本控件不依赖任何父布局,不是针对 RecyclerView. ...

  5. cell 的复用机制

    一个问题引发的血案,以下是本侦探的探案过程的一部分:以下全部都是转载自别人的博客:http://blog.sina.com.cn/s/blog_9c3c519b01016aqu.html 转自:htt ...

  6. eclipse 粘贴字符串自动添加转义符

    eclipse -> Window -> Preferences -> Java -> Editor -> Typing -> 勾选{Escape text whe ...

  7. Win10 UWP vs add github

    vs github 插件 教程 官方教程 点击查看存储库,跳转到 DemoHttp for github

  8. Tortoise SVN 使用帮助

    同步至本地:新建文件夹,SNV checkout 输入用户名密码,确认. 上传文件:将要上传的文件放在一个文件夹里,选择要上传的文件所在的文件夹,右键单击,tortoiseSVN,Import,选择要 ...

  9. 命令大全/cmd/bash

    端口占用及强杀 cmd命令 netstat -aon|findstr "8080" #查看占用pid tasklist|findstr "2448" #查看被哪 ...

  10. 【dom4j xml】使用dom4j处理XML文件--测试过程遇到的问题

    首先 关于dom4j的API,有如下: 当然  其中的实体引用有以下: 测试使用环境: 使用Maven搭建web环境,pom.xml文件配置如下: <project xmlns="ht ...