I have an asp.net web application. In this section I have an UploadFile and Button to upload a file from a client PC to a Web Server. This works on localhost where the server and client are the same, but I need for this to work on the production server with a PC connecting from the internet.
<input ID="UploadFile" runat="server" name="UploadFile" type="file" />
<asp:imagebutton id="bttnUpload" runat="server" ImageUrl="~/_images/Upload.jpg"></asp:imagebutton>
Protected Sub bttnUpload_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles bttnUpload.Click
Dim myFile As New FileInfo(UploadFile.Value)
'Set server location where file will be uploaded to.
Dim pathToCopy = Server.MapPath("~/Files/Docs/CRM/" & Session("CompCode") & "/Leads/")
'Check whether location has been created. Manually set write permissions to the directory.
If Not Exists(pathToCopy) Then
'Copy file from client to the server?
If myFile.Exists = True Then
myFile.CopyTo(pathToCopy & myFile.Name, True)
'Message file not found exit.