多个文件上传
来源:互联网 发布:mysql union all 排序 编辑:程序博客网 时间:2024/06/02 21:06
前台页面
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FileUpload .aspx.cs" Inherits="FileUpload_" %>
<!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 runat="server">
<title>上传多个文件</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="FileUpload1" runat="server" /><br />
<asp:FileUpload ID="FileUpload2" runat="server" /><br />
<asp:FileUpload ID="FileUpload3" runat="server" /><br />
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /><br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </div>
</form>
</body>
</html>
后台程序
protected void Button1_Click(object sender, EventArgs e)
{
string filepath = "C://Uploads";
HttpFileCollection uploadedFiles = Request.Files;
for (int i = 0; i < uploadedFiles.Count; i++)
{
HttpPostedFile userPostedFile = uploadedFiles[i];
try
{
if (userPostedFile.ContentLength > 0 )
{
string str1 = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() +
DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() +
userPostedFile.FileName.Substring(userPostedFile.FileName.LastIndexOf("//") + 1);//取文件名
userPostedFile.SaveAs(filepath + "//" +str1); //保存文件
}
}
catch (Exception Ex)
{
Label1.Text += "Error: " + Ex.Message;
}
}
}
- 多个文件上传
- 上传多个文件
- 上传多个文件
- 多个文件上传
- 多个文件上传
- 上传多个文件范例!
- 关于上传多个文件
- 上传多个文件问题
- java上传多个文件
- 上传多个图片文件
- 一次上传多个文件
- 同时上传多个文件
- 一次上传多个文件
- . net多个文件上传
- 上传任意多个文件
- mediawiki上传多个文件
- php 上传多个文件
- php上传多个文件
- javascript中获取单选按钮值和下拉框值的方法
- Java多线程程序设计
- Visual Basic CommonDialog 控件的使用
- [转]Unix入侵检查
- [转]Linux入侵检查
- 多个文件上传
- 常用的eclipse插件
- 精
- 中层管理技能
- Initialize reference type static fields inline
- 谈非模态对话框的销毁
- 有关XML的编码问题
- 我的USB设备有问题
- 我就不信CSDN没有高人能做,悬赏5K求算法