问题~~上传文件后怎么判断~是否上传完毕?并显示以上传的文件
解决方案 »
- Visual Web Developer2005 同 Visual Studio 2005的关系??
- ·请问书中一段代码 在线等!~~~~~~~~~
- 求救 实在不擅长asp 数据库驱动 用的access
- 添加奇异符号时所遇到的问题
- 用户控件使用的问题, 高分请教
- ashx 文件里怎么写代码读取数据库里的WORD等文件并显示呢?
- 本人初学.net 运用Ajax来实现动态树形菜单,但是一直显示不出来数据库里的数据,求大神指教
- 急死我了,windows组件更新光盘是第几张呀?
- 怎样立即删除Cookie所在的文件?
- 有关水晶报表的发布问题(未能加载数据库信息)
- 提问~~~文件上传问题~~~
- 怎么生成序列号,给一个思路
同样地,直接显示文件名加链接即可显示文件。
this.RegisterClientScriptBlock("loadUploadFileScript",GetScriptStr(Request.QueryString["method"],ubbStr));
{
return @"
<script language=javascript>
parent." + method + @"('" + text + @"');
alert(""上传完成!"");
</script>
";
}
{
//遍历File表单元素
HttpFileCollection files = HttpContext.Current.Request.Files;
DateTime dt=DateTime.Now;
string strPath=System.Configuration.ConfigurationSettings.AppSettings["uploadpath"].ToString();
try
{
for(int iFile = 0; iFile < files.Count; iFile++)
{
HttpPostedFile postedFile = files[iFile];
string fileName,linkName;
fileName = System.IO.Path.GetFileName(postedFile.FileName);
if (fileName != "")
{
// System.IO.Stream imgdatastream = postedFile.InputStream;
// int imgdatalen = postedFile.ContentLength;
// byte[] imgdata = new byte[imgdatalen];
// int n = imgdatastream.Read(imgdata,0,imgdatalen);
DataTable tmpDt=(DataTable)ViewState["filesDt"];
DataRow dr=tmpDt.NewRow();
dr[0]=fileName;
dr[1]=Session["ID"].ToString()+"_"+dt.Year+dt.Month+dt.Day+dt.Hour+dt.Minute+dt.Second+System.IO.Path.GetExtension(fileName);
linkName=dr[1].ToString();
tmpDt.Rows.Add(dr);
ViewState["filesDt"]=tmpDt; //实现上传
string pathStr=strPath+linkName;
if (System.IO.Directory.Exists(strPath))
{
postedFile.SaveAs(pathStr);
}
else
{
System.IO.Directory.CreateDirectory(strPath);
postedFile.SaveAs(pathStr);
}
// this.fileName.Value+=fileName+";";
// this.linkName.Value+=linkName+";";
//邦定文件列表
this.binderDrgFiles();
WebCommon.ShowMsg(this,"附件上传成功");
}
else
WebCommon.ShowMsg(this,"请选择要上传的文件");
}
}
catch(Exception err)
{
WebCommon.ShowMsg(this,err.Message);
}
}
Dim filesplit() As String = Split(File1.PostedFile.FileName, "\")
Dim filename As String = filesplit(filesplit.Length - 1)
File1.PostedFile.SaveAs("D:\wwwroot\WebService1\QZzhonghang" & "\" & Year(Now()) & Month(Now()) & Day(Now()) & filename)
DIV1.InnerHtml = "文件名称:" & File1.PostedFile.FileName & "<br>" & _
"文件类型:" & File1.PostedFile.ContentType & "<br>" & _
"文件大小:" & File1.PostedFile.ContentLength