zoukankan
html css js c++ java
Input控件上传文件
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <form action="exec/Upload.ashx" enctype="multipart/form-data" method="post"> <input name="file" type="file" /> <input type="submit" value="提交" /> </form> </body> </html>
页面1里面写这些
<%@ WebHandler Language="C#" Class="Upload" %> using System; using System.Web; public class Upload : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; HttpFileCollection imgs = context.Request.Files; if (imgs.Count>0) { for (int i = 0; i < imgs.Count; i++) { if (imgs[i].ContentLength!=0) { string oldName=imgs[i].FileName.ToString(); string imgName = Guid.NewGuid().ToString(); string imgType = oldName.ToString().Substring(oldName.LastIndexOf(".")); string imgPath = "~/upload/" + imgName + imgType; imgs[i].SaveAs(context.Server.MapPath(imgPath)); } } } } public bool IsReusable { get { return false; } } }
一般处理程序代码
点击下载源代码
查看全文
相关阅读:
Websocket基础知识简记
jmeter websocket接口测试
软件测试的艺术 笔记(上)
错误提示Unable to preventDefault inside passive event listener解决方法
vue-cil3关闭eslint语法检查
mongoDB无法启动服务器
Vue之todoList
react踩坑第一章
父组件向孙子组件传值(Context)特性
变量声明
原文地址:https://www.cnblogs.com/javawebsoa/p/2458006.html
最新文章
【安卓】adb not responding if youd like to retry...
【安卓】android studio一打字就卡,磁盘99%问题!!!
github 上 Fork 别人的项目后的常用的操作指南
XShell瓷砖阵列的使用
安装mysql警告Header V3 DSA/SHA1 Signature, key
Linux下Mysql修改密码 重启mysql服务
关于docker的网络映射管理
docker容器和镜像的删除,以及基本的管理启停
如何进入docker容器
docker镜像的导入导出
热门文章
docker的基本管理
docker是啥
数据库权限体系----权限与权利
尝试electron桌面APP的UI自动化测试框架
docker 命令(未完...)
VMware 安装centos 8 dvd
adb 环境搭建
性能测试理论简记
2021面试总结
websocket 如何发送音频数据
Copyright © 2011-2022 走看看