<input type="file" id="myfile" runat=server>
myfile.PostedFile.FileName是文件的全路径,包括名。
如果想获取文件名,只能自己截取字符串了。
myfile.postedfile.filename(myfile.postedfile.filename.lastindexof("/"))
myfile.PostedFile.FileName是文件的全路径,包括名。
如果想获取文件名,只能自己截取字符串了。
myfile.postedfile.filename(myfile.postedfile.filename.lastindexof("/"))
解决方案 »
- .net reactor 怎么使用,本人英语不好,高分求了。
- iframe页面刷新问题。
- 100分求Maxtocode专业版(无日期限制的),用来加密vs2005做的网站程序的dll.
- [求助] 加载配置文件时出错,对路径“c:\inetpub\wwwroot\web.config”的访问被拒绝。
- 页面传递中文问题
- 页面跳转的时候为什么会出现字体突然变大的情况?(在线等!!!)
- DataGrid可不可以实现这样的显示??在线等
- 100 ~ 求Duwamish7数据库!!
- 非常容易,请大家任意发挥。 顺便送分!
- 怎么在aspx页面写for循环,把图片读取出来
- 怎么在ASP.NET中使用Microsoft Word文档?有谁有源代码??谢谢
- 怎樣抓出表裡面某一行的資料?
string path = @"C:\mydir\";
string result;result = Path.GetFileName(fileName);
string path = @"C:\mydir\";
string result;result = Path.GetFileNameWithoutExtension(fileName);
dim file as httppostedfile=fileup.postedfileif file.contentlength<>0 then
'显示上传文件的信息
msg.text="大小:"&file.contentlength
msg.text &="<br>类型:"&file.contenttype
msg.text &="<br>名称:"&file.filename
'存储文件
dim filesplit() as string=split(file.filename,"\")
dim filename as string=filesplit(filesplit.length-1)
file.saveas(server.mappath(filename))
end if
next
end sub
file.filename就能显示出你说的路径和文件名
filename属性:读取上传文件的名称,含完整路径
pathandfilename=File1.PostedFile.FileName; //客户端文件(包含路径)
filename=File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf('\\')+1);//客户端文件名称(不包含路径)
<%
Response.buffer=true;
%>
<HTML>
<TITLE>Repost Example</TITLE>
<BODY>
<H1>Upload Status</H1>
<P>
Destination: <B><% Response.Write(Request.Form("TargetURL")) %></B>
</P>
<%
Response.write("<P>Name: " + Request.Form("FileName") + "</P>");
Response.write("<P>Size: " + Request.Form("FileSize") + "</P>");
Response.write("<P>Path: " + Request.Form("FilePath") + "</P>");
%>
</BODY>
</HTML>
Dim fileName, fileExtension As System.String
fileName = System.IO.Path.GetFileName(postedFile.FileName)