E
egsdar
Hello, I have already created the script to upload a file (but locally) and
I'd like to upload it on my remote server, how can I do this?
this is my code:
Sub Upload(ByVal Source As Object, ByVal e As EventArgs)
If Not (myFile.PostedFile Is Nothing) Then
Dim intFileNameLength As Integer
Dim strFileNamePath As String
Dim strFileNameOnly As String
'Logic to find the FileName (excluding the path)
strFileNamePath = MyFile.PostedFile.FileName
intFileNameLength = Instr(1, StrReverse(strFileNamePath), "\")
strFileNameOnly = Mid(strFileNamePath, (Len(strFileNamePath) -
intFileNameLength) + 2)
Dim nombrearchivo As String
nombrearchivo = "C:\Inetpub\wwwroot\Proyectos\Documentos\" & strFileNameOnly
myFile.PostedFile.SaveAs(nombrearchivo)
lblMsg.Text = "El archivo se subió con exito."
Dim sqlConn As System.Data.SqlClient.SqlConnection
Dim sqlCmd As System.Data.SqlClient.SqlCommand
Dim strConnection, resul As String
strConnection =
ConfigurationManager.ConnectionStrings("SIPConnectionString").ConnectionString
sqlConn = New System.Data.SqlClient.SqlConnection(strConnection)
sqlCmd = New System.Data.SqlClient.SqlCommand("Insert into
documentos(idpropuesta, nombre) values(" & Request.QueryString("mivar") & ",
'" & nombrearchivo & "')", sqlConn)
sqlConn.Open()
resul = sqlCmd.ExecuteNonQuery
sqlConn.Close()
GridView1.DataBind()
End If
End Sub
With this current code is displaying an error :
Cannot find the current path "c:\inetpub\wwwroot\Sip\documents"
I'd like to upload it on my remote server, how can I do this?
this is my code:
Sub Upload(ByVal Source As Object, ByVal e As EventArgs)
If Not (myFile.PostedFile Is Nothing) Then
Dim intFileNameLength As Integer
Dim strFileNamePath As String
Dim strFileNameOnly As String
'Logic to find the FileName (excluding the path)
strFileNamePath = MyFile.PostedFile.FileName
intFileNameLength = Instr(1, StrReverse(strFileNamePath), "\")
strFileNameOnly = Mid(strFileNamePath, (Len(strFileNamePath) -
intFileNameLength) + 2)
Dim nombrearchivo As String
nombrearchivo = "C:\Inetpub\wwwroot\Proyectos\Documentos\" & strFileNameOnly
myFile.PostedFile.SaveAs(nombrearchivo)
lblMsg.Text = "El archivo se subió con exito."
Dim sqlConn As System.Data.SqlClient.SqlConnection
Dim sqlCmd As System.Data.SqlClient.SqlCommand
Dim strConnection, resul As String
strConnection =
ConfigurationManager.ConnectionStrings("SIPConnectionString").ConnectionString
sqlConn = New System.Data.SqlClient.SqlConnection(strConnection)
sqlCmd = New System.Data.SqlClient.SqlCommand("Insert into
documentos(idpropuesta, nombre) values(" & Request.QueryString("mivar") & ",
'" & nombrearchivo & "')", sqlConn)
sqlConn.Open()
resul = sqlCmd.ExecuteNonQuery
sqlConn.Close()
GridView1.DataBind()
End If
End Sub
With this current code is displaying an error :
Cannot find the current path "c:\inetpub\wwwroot\Sip\documents"