N
Nathan Sokalski
I have a form that allows the user to upload a file. Even though <input
type="file" runat="server"> is intended to have the user choose the file
using the browse button, it still allows them to change the path before it
is uploaded. I currently use the following code to upload the file:
Dim upfilename As String = ""
If fileDetails.Value <> "" Then
Dim dir As String() =
fileDetails.PostedFile.FileName.Split("\".ToCharArray())
upfilename = dir(dir.GetUpperBound(0))
fileDetails.PostedFile.SaveAs(Server.MapPath("/") & upfilename)
End If
I use an If statement to make sure something is there, but I want to make
sure the file that it refers to is actually there before trying to perform
the upload. How can I do this? The fact that it is sometimes hard to look at
the client's hard drive (due to security reasons) I do not know how to make
sure the file actually exists, and I want to do everything possible to
prevent my users from seeing error messages. Thanks.
type="file" runat="server"> is intended to have the user choose the file
using the browse button, it still allows them to change the path before it
is uploaded. I currently use the following code to upload the file:
Dim upfilename As String = ""
If fileDetails.Value <> "" Then
Dim dir As String() =
fileDetails.PostedFile.FileName.Split("\".ToCharArray())
upfilename = dir(dir.GetUpperBound(0))
fileDetails.PostedFile.SaveAs(Server.MapPath("/") & upfilename)
End If
I use an If statement to make sure something is there, but I want to make
sure the file that it refers to is actually there before trying to perform
the upload. How can I do this? The fact that it is sometimes hard to look at
the client's hard drive (due to security reasons) I do not know how to make
sure the file actually exists, and I want to do everything possible to
prevent my users from seeing error messages. Thanks.