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; } } }
一般处理程序代码
点击下载源代码
查看全文
相关阅读:
Codeforces Round #365 Div.2
Codeforces Round #363 Div.2[111110]
花花的礼物 (huahua)
FOI2019算法冬令营D1
树(tree)
noip2018
1972: 最短路(shortest)
2462: 收集(collecting)
1282: 排列计数 perm
1425: 数列(seq)
原文地址:https://www.cnblogs.com/javawebsoa/p/2458006.html
最新文章
[loj2478]林克卡特树
[loj2477]劈配
[loj2473]秘密袭击
[loj3273]扫除
[loj3049]字符串问题
[luogu6185]序列
[loj3048]异或粽子
[loj3274]变色龙之恋
[bzoj1264]基因匹配
[bzoj4036]按位或
热门文章
[bzoj1145]图腾
[luogu5204]Train Tracking 2
Codeforces Round #367 Div. 2
Educational Codeforces Round 15 [111110]
最长上升子序列[LIS]
Mishka and Divisors[CodeForces Round #365 Div.2]
Codeforces Round #366 Div.2[11110]
如何黑掉一台根本不联网的电脑?
想说爱你真难
2016.8.6
Copyright © 2011-2022 走看看