文件上传问题?救命呀 在asp.net中如果知道客户端c盘下有一个文件test.txt,怎么在页面中把这个文件隐式上传到服务器上,也就是不用<input type=file>,不用客户端用户选择这个文件,直接就可以上传这个文件,请问高手怎么解决了?不要用adodb.stream方式,谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 WebClient.UploadFile 这个我用了,这个上传的是服务器目录下的文件,而不是客户端的文件 webclient.aspx:<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" %><%@ Import Namespace="System"%><%@ Import Namespace="System.IO"%><%@ Import Namespace="System.Net"%><%@ Import NameSpace="System.Web"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>无标题文档</title><Script language="C#" runat=server>void Page_Load(object sender, EventArgs e) { foreach(string f in Request.Files.AllKeys) { HttpPostedFile file = Request.Files[f]; file.SaveAs(Server.MapPath(file.FileName)); } }void button_click(object sender, EventArgs e) {System.Net.WebClient webClient = new System.Net.WebClient(); byte[] responseArray = webClient.UploadFile(this.textBox2.Text,"POST",this.textBox1.Text); }</Script></head><body><form runat="server"><p> Upload complete. </p><asp:TextBox ID="textBox1" runat="server" Text="C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\_NetworkingPerfCounters.h"></asp:TextBox><asp:TextBox ID="textBox2" runat="server" Text="http://localhost/webclient.aspx"></asp:TextBox><asp:Button ID="botton1" OnClick="button_click" Text="uploadFile" runat="server"></asp:Button></form></body></html> 我想也许不能实现了,不过我请教一个其他问题,dwf图形文件在网页上直接标记修改,怎么直接保存到服务器上了? DataTable 导入Execl 出现错误~!急急急急急!!! 网站首次打开出现的问题 怎么找回MS2005数据库administrator管理员 关于统计~! 怪事天天有,今天特别多.有谁能解释一下这个诡异事件? 我想学ASP.NET不知道从哪儿入手?? 路过也有分!!!项目发布时路么的问题 路过也有分!!! 高分请教:把下载的控件添加到工具箱中的问题??? 为什么在.apx.vb里面如何如何写imports这个函数?咳!手上没有分,多谢指教! 大虾救命呀~page_load中执行两条sql语句??? 我用js读xml中读出的节点为什么是null 急求机票预订系统的脚本~~谢谢
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" %>
<%@ Import Namespace="System"%>
<%@ Import Namespace="System.IO"%>
<%@ Import Namespace="System.Net"%>
<%@ Import NameSpace="System.Web"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<Script language="C#" runat=server>
void Page_Load(object sender, EventArgs e) {
foreach(string f in Request.Files.AllKeys) {
HttpPostedFile file = Request.Files[f];
file.SaveAs(Server.MapPath(file.FileName));
}
}
void button_click(object sender, EventArgs e) {
System.Net.WebClient webClient = new System.Net.WebClient();
byte[] responseArray = webClient.UploadFile(this.textBox2.Text,"POST",this.textBox1.Text);
}
</Script>
</head>
<body>
<form runat="server">
<p> Upload complete. </p>
<asp:TextBox ID="textBox1" runat="server" Text="C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\_NetworkingPerfCounters.h"></asp:TextBox>
<asp:TextBox ID="textBox2" runat="server" Text="http://localhost/webclient.aspx"></asp:TextBox>
<asp:Button ID="botton1" OnClick="button_click" Text="uploadFile" runat="server"></asp:Button>
</form>
</body>
</html>