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; } } }
一般处理程序代码
点击下载源代码
查看全文
相关阅读:
文件的权限
正则表达式
软硬链接的学习
linux系统中的文件类型和扩展名
把数组排成最小的数
整数中1出现的次数(从1到n整数中1出现的次数)
最小的K个数
连续子数组的最大和
数组中出现次数超过一半的数字
字符串的排列
原文地址:https://www.cnblogs.com/javawebsoa/p/2458006.html
最新文章
SpringCloud-技术专区-Zuul过滤器修改转发的url
SpringCloud-技术专区-从zuul过滤器发送重定向
Quartz简单实现定时任务管理(SSM+Quartz)
CAS-技术专区-工作处理流程
Linux性能评测工具
Linux日志查看
Linux启动流程
Linux 终端下的颜色
linux文件比较
USB驱动分析
热门文章
linux USB 编程
USB原理简单叙述
终端学习
PCI总线学习
用户权限集中管理方案
用户管理
练习题
企业案例
crond定时任务
Linux系统文件删除原理
Copyright © 2011-2022 走看看