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; } } }
一般处理程序代码
点击下载源代码
查看全文
相关阅读:
poj2928:素数回文数的个数
R语言学习中的小bug:R中矩阵相乘错误于A %*% B: 需要数值/复数矩阵/矢量参数
poj3247:回文素数
Python爬虫之BeautifulSoap的用法
python jieba库的使用说明
彻底弄懂python编码
第八周助教总结
python中数组用法
python列表操作大全
python—各种常用函数及库
原文地址:https://www.cnblogs.com/javawebsoa/p/2458006.html
最新文章
Linux 防火墙相关操作
Docker学习笔记
C语言实现2048小游戏
数据库编程
端口占用排查
Java匿名类
递推-hdu1041 Computer Transformation
C++写geohash
在VS中如何用C++连接Mysql
整数转字符与字符转整数的C系统函数
热门文章
《漫画数学》的反思
整数分解的标程
01背包
迷宫问题的反思
hadoop 关于java中的public static 变量是不能被改变的?
poj4089:电话号码
hadoop 中遇到的jar打包时候的小问题,注意打包的时候所处的目录
R运行大数据的过程中遇到的问题:不能有负长度矢量
慎用stl中的erase的返回值
poj4093:倒排索引查询
Copyright © 2011-2022 走看看