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. BZOJ 1923: [Sdoi2010]外星千足虫

    Description 给出几个异或方程组求解,\(n \leqslant 2000\) Sol 高斯消元. 直接消元就行,遇到自由元就直接输出,同时记录一下用到的最高行数. 复杂度不科学就可以用 b ...

  2. 难道这就是JavaScript中的"闭包"

    其实对于JavaScript中的"闭包"还没真正理解,这次在实际Coding中似乎遇到了"闭包"的问题,仅此摘录,以待深究. 表现为jQuery的post方法回 ...

  3. PHP多进程编程实例

    这篇文章主要介绍了PHP多进程编程实例,本文讲解的是在Linux下实现PHP多进程编程,需要的朋友可以参考下 羡慕火影忍者里鸣人的影分身么?没错,PHP程序是可以开动影分身的!想完成任务,又觉得一个进 ...

  4. JS和JQuery的总结

    JS部分 一,  词法结构 区分大小 注意://单行  /*多行注释*/ 字面量(直接量literal) 12 // 数字 5.8//小数 "hello" 'hello' true ...

  5. 解决NSData转NSString返回nil的问题

    // 字符串转Data NSString *str =@"jesfds"; NSData *data =[str dataUsingEncoding:NSUTF8StringEnc ...

  6. 网络编程之addrinfo

    addrinfo结构体定义如下: typedef struct addrinfo { int ai_flags;//指示在getaddrinfo函数中使用的选项的标志. int ai_family; ...

  7. AngularJS 表格

    ng-repeat 指令可以完美的显示表格. 使用 angular 显示表格是非常简单的: <!DOCTYPE html> <html> <head> <me ...

  8. Pyqt 获取打包二进制文件中的资源

    记得有一次打开一个单独exe程序,点击btn中的一个帮助说明按钮,在同级目录下就多出一个help.chm 文件并自动打开. 那这个exe肯定是把help.chm 打包到exe中,当我触发“帮助”按钮的 ...

  9. 联合体(union)的使用方法及其本质

    转自:http://blog.csdn.net/huqinwei987/article/details/23597091 有些基础知识快淡忘了,所以有必要复习一遍,在不借助课本死知识的前提下做些推理判 ...

  10. freemarker内置函数和用法

    原文链接:http://www.iteye.com/topic/908500 在我们应用Freemarker 过程中,经常会操作例如字符串,数字,集合等,却不清楚Freemrker 有没有类似于Jav ...