一个关于postedFile的问题,请孟子老大帮忙看看。
Private Sub upload_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles upload.ServerClick
Dim files As System.Web.HttpFileCollection = System.Web.HttpContext.Current.Request.Files
Dim iFile As System.Int32
Try
Dim postedFile As System.Web.HttpPostedFile = files(iFile)
Dim fileName, fileExtension As System.String
Dim Temp() As String = Split(fupload.PostedFile.FileName, "\ ")
fileName = Temp(Temp.Length - 1)
If Not (fileName = String.Empty) Then
fileExtension = System.IO.Path.GetExtension(fileName)
txtPicPath.Text = Server.MapPath( "..\product\ ") & fileName
fupload.PostedFile.SaveAs(Server.MapPath( "..\product\ ") & fileName)
End If
Catch Ex As Exception
Response.Write(Err.Description)
End Try
End Sub
---------------------------
以上是代码,为什么我在本地调试是正常的,但上传到虚拟主机上,通过internet访问时,文件就不能成功上传,也没有任何错误信息显示。
老大能帮忙看看错在哪里吗?
------解决方案--------------------Server.MapPath( "..\product\ ") & fileName
是否给 ASP.NET 账户分配对于该目录的写权限?!
------解决方案--------------------可以直接把服务器上的地址传进去嘛;
楼主可以把应用程序所自的根目录放在config文件里方便以后修改