I am trying to upload a file and cannot get it to work. I have the correct url for the site and sub-folder. I have tried fileUploader.FileName
and fileUploader.SaveAs
as well. None seem to work. It is not in an UpdatePanel
. Any ideas?
Code behind:
Protected Sub uploader_click(sender As Object, e As EventArgs) Handles btnUpload.Click
If fileUploader.HasFile Then
Dim _path As String = Path.Combine("{path to site and folder}", Server.HtmlEncode(fileUploader.PostedFile.FileName))
Try
fileUploader.PostedFile.SaveAs(_path)
Catch ex As Exception
Response.Write(ex.ToString)
End Try
Else
Response.Write("No File")
End If
End Sub
New code, I need to get parent folder to expose the sub folder:
Dim filePath = Path.GetFileName(fileUploader.PostedFile.FileName)
Dim _path As String = Path.Combine(Server.MapPath("~"), "subfolder", filePath)
_path
= \\{server blah}\{site}\webroot
Now no error, but no file uploaded either???