fineuploader使用实例
来源:互联网 发布:java软件开发简历模板 编辑:程序博客网 时间:2024/06/03 17:56
1、Fine Uploader特点
Fine Uploader Features:
A:支持文件上传进度显示.
B:文件拖拽浏览器上传方式
C:Ajax页面无刷新.
D:多文件上传.
F:跨浏览器.
E:跨后台服务器端语言.
2、页面前端代码
<div id="btnUpload"></div>
$(function () { $('#btnUpload').fineUploader({ request: { endpoint: 'Handler/UpLogo.ashx' }, validation: { allowedExtensions: ['jpeg', 'jpg', 'png'] }, multiple: false, text: { uploadButton: '<div>上传头像</div>' } }).on('complete', function (event, id, fileName, responseJson) { if (responseJson.success) { $("#absoluteUrl").val(responseJson.path); $("#jcrop_target").attr("src", responseJson.url); $("#jcrop_target").css({ "width": 300, "height": 300 }); $("#preview").attr("src", responseJson.url); $("#preview").css({ "width": 100, "height": 100 }); ias.update(); } }); });
2、Handler文件代码
<%@ WebHandler Language="C#" Class="UpLogo" %>using System;using System.Web;using System.IO;using System.Text;using System.Net;using System.Data;using System.Collections;using System.Collections.Generic;using System.Drawing;using ECS.Utility;public class UpLogo : IHttpHandler{ public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; if (context.Request != null && context.Request.Files.Count > 0) { var HttpFile = context.Request.Files[0]; var allowedExt = new List<string> { ".jpg", ".gif", ".bmp", ".png" }; var fileExt = Path.GetExtension(HttpFile.FileName).ToLower(); var File_Name = Path.GetFileNameWithoutExtension(HttpFile.FileName); var toFileName = Guid.NewGuid().ToString() + fileExt; var toFileFullPath = context.Server.MapPath("~/UpFiles/UserTemFace/"); var viewPath = "/UpFiles/UserTemFace/"; var Title = File_Name; DirectoryInfo di = new DirectoryInfo(toFileFullPath); if (!di.Exists) { di.Create(); } ECS.Model.A_User Model = new ECS.BLL.A_User().GetModel(ValUtil.GetUserID()); if (Model != null) { //toFileName = Model.UserFaceImg; string saveFile = toFileFullPath + toFileName; //先删除临时文件 //var _filePath = toFileFullPath + "\\" + toFileName; //if (File.Exists(_filePath)) //{ // FileInfo fi = new FileInfo(_filePath); // if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1) // { // fi.Attributes = FileAttributes.Normal; // } // File.Delete(_filePath); //} HttpFile.SaveAs(saveFile); Model.UserFaceImg = toFileName; new ECS.BLL.A_User().Update(Model); } string imgeUrl = ""; if (fileExt.ToLower().Equals(".jpg") || fileExt.ToLower().Equals(".gif") || fileExt.ToLower().Equals(".bmp") || fileExt.ToLower().Equals(".png")) { imgeUrl = viewPath + toFileName; } else { context.Response.Write("{success:false,msg:'只能上传图片类型的文件'}"); context.Response.End(); return; } string url = viewPath + "/" + toFileName; context.Response.Write(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(new { success = true, url = url, path = toFileName })); context.Response.End(); } else { context.Response.Write(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(new { success = false })); context.Response.End(); } } public bool IsReusable { get { return false; } }}
0 0
- fineuploader使用实例
- FineUploader使用心得
- asp.net 使用纯jquery上传控件 fineuploader实现多文件上传
- 使用FineUploader 上传大文件设置IIS7文件上传的最大大小 maxAllowedContentLength,maxRequestLength
- 上传文件(FineUploader)插件
- FineUploader 参数 上传 和 后台接收
- FineUploader 结合 一般处理程序 【上传示例】
- [置顶] fineuploader 跨子域上传文件 cookie丢失问题的解决
- FineUploader文件/图片和form表单参数一起上传,从入门到精通教程
- 避免使用实例陷阱
- SAFEARRAY使用实例
- log4j使用实例
- VSS使用实例1
- Label使用实例
- classpath使用故障实例
- Timer使用实例
- 使用实例文档
- DataList使用实例
- python安装第三方模块(windows环境)
- Ios基本控件 坐标获取 ,一般就有以下几种情况
- BAT及各大互联网公司2014前端笔试面试题:HTML/CSS篇
- 几种常见的xml解析方式 SAX,DOM,PULL以android为例
- 符合地方和
- fineuploader使用实例
- ffmpeg+xvid+x264交叉编译全过程
- 怎样让机器学会检测人脸——1、统计学习
- 老公给我讲算法(二)时间复杂度分析之均摊分析
- VC包含目录、附加依赖项、库目录及具体设置
- 安卓访问web
- Linux与JVM的内存关系分析
- 国外C++ 程序员收藏
- ASIHTTPRequest类库简介和使用说明