1. public void ProcessRequest (HttpContext context) {
  2. if (true) {
  3. context.Response.ContentType = "text/plain";
  4. result result = new result();
  5. string fileNewName = string.Empty;
  6. string filePath = string.Empty;
  7. HttpFileCollection files = context.Request.Files;
  8. if (files.Count > )
  9. {
  10. //设置文件名
  11. fileNewName = DateTime.Now.ToString("yyyyMMddHHmmssff") + "_" + System.IO.Path.GetFileName(files[].FileName);
  12. //保存文件
  13. files[].SaveAs(context.Server.MapPath("../Files/" + fileNewName));
  14. result.code = "";
  15. result.msg = "文件上传成功!";
  16. }
  17. else {
  18. result.code = "";
  19. result.msg = "文件上传失败!";
  20. }
  21. context.Response.Write(new JavaScriptSerializer().Serialize(result));
  22. context.Response.End();
  23. }
  24. }
  25. public class result{
  26. public string code { get; set; }
  27. public string msg { get; set; }
  28. }
  1. //创建上传组件
  2. upload.render({
  3. elem: '#uploadBtn',
  4. url: './FileOption.ashx',
  5. dataType:"json",
  6. accept: 'file', //允许上传的文件类型
  7. size: , //最大允许上传的文件大小,
  8. data: function () {
  9. //请求上传接口的额外参数
  10. },
  11. done: function (res) {
  12. if (res.code === "") {
  13. layer.msg(res.msg);
  14. } else {
  15. layer.msg(res.msg);
  16. }
  17. },
  18. error: function () {
  19. layer.msg("请求异常!");
  20. }
  21. });

上传文件-layui+ashx的更多相关文章

  1. 完整uploadify批量上传文件插件使用

    1.首先准备uploadify的js文件,网上一搜一大堆 2.上传页面UpFilePage.aspx 关键代码: <html xmlns="http://www.w3.org/1999 ...

  2. IIS8中 出现ashx 401:未授权,uploadify上传文件失败

    环境:阿里云服务器 windows2012  + IIS8 +asp.net 访问IIS 出现能正常访问aspx页面,但是通过ajax访问ashx上传文件的时候就出现ashx  Status Code ...

  3. ajax+ashx 完美实现input file上传文件

    1.input file 样式不能满足需求 <input type="file" value="浏览" /> IE8效果图:    Firefox效 ...

  4. layui上传文件配合进度条

    首先看一下效果图: 修改layui的源文件upload.js 1.打开layui/modules/upload.js 2.搜索ajax 3.找到url: 4.添加以下代码: ,xhr:l.xhr(fu ...

  5. layui结合SpringMVC上传文件以及携带额外的参数上传文件

    今天在使用layui的过程中,遇到了使用其上传文件的模块.自己感觉文件上传还是bootstrapfileinput插件比较好用一些,灵活方便,bootstrapfileinput使用方法参考:http ...

  6. Layui上传文件以及数据表格

    layui对于一些前端小白来说,例如我,真的非常的好用,不用去花很多很多的心思在前端美化中,并且提高了很大的工作效率.所以建议一些觉得自己前端技术不是很强,但是想让前端美化一点的可以使用layui. ...

  7. layui上传文件组件(前后端代码实现)

    我个人博客系统上传特色图片功能就是用layui上传文件组件做的.另外采用某个生态框架,尽量都统一用该生态框架对应的解决方案,因为这样一来,有这么几个好处?1.统一而不杂糅,有利于制定相应的编码规范,方 ...

  8. layui上传文件前加入确认提示

    //上传文件 upload: function () { layui.use('upload', function () { var upload = layui.upload; //执行实例 var ...

  9. ASP.NET、JAVA跨服务器远程上传文件(图片)的相关解决方案整合

    一.图片提交例: A端--提交图片 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string u ...

随机推荐

  1. Linux 连接memcache 拒绝连接,防火墙关闭,selinux disabled 仍然不行,最后在外站找到原因,为服务器添加memcache访问权限

    最后啊,不行,直接装memcached  https://www.runoob.com/memcached/memcached-install.html 附上连接:https://www.presta ...

  2. office web apps 在线问答预览

    最近在做项目时,需要用到在线文档预览,看过明道的一篇搭建office web apps服务的文章,但是由于时间的关系,没有仔细研究,这几天有时间,就拿出来研究了下,折腾了几天终于完成了部署,然后就搬过 ...

  3. windows下搭建基于nginx的rtmp服务器

    https://blog.csdn.net/fireroll/article/details/51985688 Windows机器配置:Windows7旗舰版 64位Intel(R) Core(TM) ...

  4. vue 自定义全局方法

    import {myfun} from '../static/js/test.js' //se6的正确写法export default {methods:{ diyfun:function () { ...

  5. Django开发简单采集用户浏览器信息的小功能

    Django开发简单采集用户浏览器信息的小功能 Centos环境准备 yum install –y python-pip export http_proxy=http://10.11.0.148:80 ...

  6. web端安全测试工具

    https://www.cnblogs.com/ios9/p/7692373.html 十大web安全扫描工具 扫描程序可以在帮助造我们造就安全的Web 站点上助一臂之力,也就是说在黑客“黑”你之前, ...

  7. Rust基础笔记:闭包

    语法 Closure看上去是这样的: let plus_one = |x: i32| x + 1; assert_eq!(2, plus_one(1)); 首先创建一个绑定plus_one,然后将它分 ...

  8. vmware安装密钥

    VMware虚拟机已升级至14版本,之前的12版本的秘钥已经无法使用,在此分享一下VMware Workstation 14永久激活密钥: CG54H-D8D0H-H8DHY-C6X7X-N2KG6 ...

  9. Win10使用mysqldump导出csv文件及期间遇到的问题

    作为测试,我们这里使用了名为testdb的数据库中的名为test_table的表,首先我们使用如下SQL来查看其中有何数据: select * from testdb.test_table 数据如下: ...

  10. AWS 存储服务(三)

    目录 AWS S3 业务场景 挑战 解决方案 S3的好处 S3 属性 存储桶 Buckets 对象 Object S3 特性 S3 操作 可用性和持久性 一致性 S3 定价策略 S3高级功能 存储级别 ...