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. JS正则表达式元字符

    https://segmentfault.com/a/1190000002471140

  2. ftp服务配置文件记录

    因为南京的客户死活要ftp服务而不是sftp,所以我作手用vsftp作为服务器,尝试在windows ftp软件登录进去,特记录vsftp的用法. 配置文件在/etc/vsftpd.conf 有如下代 ...

  3. 十三. JEB破解三

    一.启动环境 JEB 2.0Demo版本启动后出现这样一个界面 当前环境算出的许可证数据 48000000BDEAE192E4CEFC82B34C2AC67F3A85DF5C0E262E421772C ...

  4. Excel 点滴积累

    1.Excel中截取邮件@之后的字符 MID(text, start_num, num_chars) FIND(find_text,within_text,start_num) Right(strin ...

  5. POJ 3155 Hard Life(最大密度子图)

    裸题.输入一个无向图,输出最大密度子图(输出子图结点数和升序编号). 看了<最小割模型在信息学竞赛中的应用——胡伯涛>的一部分,感觉01分数规划问题又是个大坑.暂时还看不懂. 参考http ...

  6. webstorm抽取函数

    webstrom 1.extact 抽取函数:选中代码,右键,refactor-extact function matchPicLink() { var $match = $('#match'); v ...

  7. 51nod1118(水题)

    题目链接: https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1118 题意: 中文题诶~ 思路: 因为机器人只能往下或者右 ...

  8. AngularJS Select(选择框)

    AngularJS 可以使用数组或对象创建一个下拉列表选项. 使用 ng-option 创建选择框 在 AngularJS 中我们可以使用 ng-option 指令来创建一个下拉列表,列表项通过对象和 ...

  9. Linux常用命令学习4---(挂载命令mount umount、用户登陆查看和用户交互命令 w who last lastlog)

    紧接着上一篇Linux的命令行的学习:Linux学习3---(文件的压缩和解压缩命令zip unzip tar.关机和重启命令shutdown reboot……) 1.挂载命令     简介      ...

  10. 【leetcode】Maximum Subarray (53)

    1.   Maximum Subarray (#53) Find the contiguous subarray within an array (containing at least one nu ...