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; } } }
一般处理程序代码
点击下载源代码
查看全文
相关阅读:
js 鼠标事件大全
ASP.NET 解决重复提交问题
C# 统计函数运行时间
DataGrid 、Repeater、DataList、GridView自动编号列
两种时间格式正则表达式HH:mm 和HH:mm:ss
SQL Server2008 新语法
XYTipsWindow 2.8
MSSQL 清空日志
SQL 日期格式化大全
HDOJ 2132
原文地址:https://www.cnblogs.com/javawebsoa/p/2458006.html
最新文章
Linux 下的查找
XCode 在系统抛出异常处设置断点
Mysql 复制表
IOS 难理解的几个屏幕接触问题
用Curl测试POST
[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] ERROR
Mysql 数据库导入导出
vim 中的查找
PostgreSQL数据的导出导入
AjaxUpload
热门文章
一款不错的Jquery插件——获取URL参数(转载)
异构数据库同步问题
Aspose实现读取/ 写入Excel初探及相关问题的提出
常见的C#实现导出到Excel 功能
C#操作Mysql数据库
Web表单验证中正则表达式应用初探
NET环境下Jquery操作JSON初探
GridView自定义分页及其他示例
C#中调用存储过程的简单示例
GridView 多表头解决方法
Copyright © 2011-2022 走看看