runxinzhi.com
首页
百度搜索
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下对/sys/class/gpio中的gpio的控制
-bash: ./reset_lgw.sh: /bin/sh^M: bad interpreter: No such file or directory
MakeFile杂记
MakeFile = := ?= += 的区别
Linux 系统及编程相关知识总汇
node-webkit开发桌面应用
PHP 合理配置实现文件上传及保存文件到数据库
PHP 从基础开始 ——重要知识点笔记
Linux与Windows远程互访(使用Rdesktop与SSH)
编程之路,开发之路,技术大全
原文地址:https://www.cnblogs.com/javawebsoa/p/2458006.html
最新文章
洛谷 P2059 [JLOI2013]卡牌游戏 解题报告
洛谷 P3297 [SDOI2013]逃考 解题报告
洛谷 CF55D Beautiful numbers 解题报告
CF1073E Segment Sum 解题报告
原码反码补码
课后作业-2
课堂测试
第八次进度总结
第七次进度总结
第六次进度总结
热门文章
第五次进度总结
第四次进度总结
第三次进度报告
第二次进度报告
查找php 命令行模式与 web模式配置文件所在位置
[php] Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environme
什么是phpize及其用法
阿里云LAMP环境找不到php命令
波特率
SHELL中的exit 0 和 exit 1有什么区别?
Copyright © 2020-2023
润新知