现在的位置: 首页 > 综合 > 正文

有关文件上传存储的问题

2011年03月13日 ⁄ 综合 ⁄ 共 2127字 ⁄ 字号 评论关闭
代码如下
<%@ Page Language="vb" Debug="true" %>

<html>
<script language="vb" runat=server>
sub uploadfile(sender as object, e as system.Eventargs)
    
dim s as string
    s
="d:\updata\" & system.io.path.getfilename(butimage.postedfile.filename)
    butimage.postedfile.saveas(s)
end sub

</script>
<body>
<form runat="server" enctype="multipart/form-data">
    
<input type=file runat=server id=butimage/><br>
    
<input type=button id=yesbutton onserverclick=uploadfile runat=server value="提交"/>
</form>
</body>
</html>

运行后出现问题如下:

/fileup”应用程序中的服务器错误。
--------------------------------------------------------------------------------

未找到路径“d:
\updata\boat.gif”的一部分。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 

异常详细信息: System.IO.DirectoryNotFoundException: 未找到路径“d:
\updata\boat.gif”的一部分。

源错误: 


行 
7:      dim s as string
行 
8:      s="d:\updata\" & system.io.path.getfilename(butimage.postedfile.filename)
行 
9:      butimage.postedfile.saveas(s)
行 
10: 
行 
11: end sub
 

源文件: c:
\inetpub\wwwroot\fileup\index.aspx    行: 9 

堆栈跟踪: 


[DirectoryNotFoundException: 未找到路径“d:
\updata\boat.gif”的一部分。]
   System.IO.__Error.WinIOError(Int32 errorCode, 
String str+287
   System.IO.FileStream..ctor(
String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) +888
   System.IO.FileStream..ctor(
String path, FileMode mode) +52
   System.Web.HttpPostedFile.SaveAs(
String filename) +48
   ASP.index_aspx.uploadfile(
Object sender, EventArgs e) in c:\inetpub\wwwroot\fileup\index.aspx:9
   System.Web.UI.HtmlControls.HtmlInputButton.OnServerClick(EventArgs e) 
+108
   System.Web.UI.HtmlControls.HtmlInputButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(
String eventArgument) +57
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, 
String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) 
+138
   System.Web.UI.Page.ProcessRequestMain() 
+1277

 


--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:
1.1.4322.573; ASP.NET 版本:1.1.4322.573 

请各位大侠帮我看看呀!

抱歉!评论已关闭.