Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Uploading file problem [modified]

Uploading file problem [modified]

Scheduled Pinned Locked Moved Visual Basic
helpcomsysadminxmllearning
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Darshon
    wrote on last edited by
    #1

    Hi everyone, I'm trying to upload an *.xml file to my server and this is the code I'm using. The problem I have is that I get a 403 error every time, even though my folder permissions are correct and my authentications are correct as well. Just wondering if I'm doing something wrong with my code.

    If File.Exists("C:\Documents and Settings\Denis\Desktop\GetFileTest\test.xml") Then
    Dim remoteUri As String = "http://www.site.com/folder/"
    Dim fileName As String = "C:\Documents and Settings\Denis\Desktop\GetFileTest\test.xml"
    ' Create a new WebClient instance.
    Dim myWebClient As New WebClient
    myWebClient.Credentials = New NetworkCredential("username", "password", "http://www.site.com/")
    Try
    ' The UploadFile() method uploads the current file to the Web resource-system folder.
    myWebClient.UploadFile(remoteUri, fileName)
    Label.Text = "Done!"
    Catch ex As Exception
    MessageBox.Show(ex.Message)
    End Try
    Else
    Label.Text = "No Go!"
    End If

    Thanks for any help ~D~

    modified on Friday, February 22, 2008 11:33 AM

    D 1 Reply Last reply
    0
    • D Darshon

      Hi everyone, I'm trying to upload an *.xml file to my server and this is the code I'm using. The problem I have is that I get a 403 error every time, even though my folder permissions are correct and my authentications are correct as well. Just wondering if I'm doing something wrong with my code.

      If File.Exists("C:\Documents and Settings\Denis\Desktop\GetFileTest\test.xml") Then
      Dim remoteUri As String = "http://www.site.com/folder/"
      Dim fileName As String = "C:\Documents and Settings\Denis\Desktop\GetFileTest\test.xml"
      ' Create a new WebClient instance.
      Dim myWebClient As New WebClient
      myWebClient.Credentials = New NetworkCredential("username", "password", "http://www.site.com/")
      Try
      ' The UploadFile() method uploads the current file to the Web resource-system folder.
      myWebClient.UploadFile(remoteUri, fileName)
      Label.Text = "Done!"
      Catch ex As Exception
      MessageBox.Show(ex.Message)
      End Try
      Else
      Label.Text = "No Go!"
      End If

      Thanks for any help ~D~

      modified on Friday, February 22, 2008 11:33 AM

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Darshon wrote:

      myWebClient.Credentials = New NetworkCredential("username", "password", "http://www.site.com/")

      You're specifying the domain as a URI. What this parameter should contain in the domain of the credentials you type into the Username/Password/Domain box when it shows up, if you did this manually. The domain it wants is the Windows domain where the User account is stored, not a URI. For most public websites, the domain box is left blank. So, try it without the domain parameter.

      myWebClient.Credentials = New NetworkCredential("username", "password")

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      D 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Darshon wrote:

        myWebClient.Credentials = New NetworkCredential("username", "password", "http://www.site.com/")

        You're specifying the domain as a URI. What this parameter should contain in the domain of the credentials you type into the Username/Password/Domain box when it shows up, if you did this manually. The domain it wants is the Windows domain where the User account is stored, not a URI. For most public websites, the domain box is left blank. So, try it without the domain parameter.

        myWebClient.Credentials = New NetworkCredential("username", "password")

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        D Offline
        D Offline
        Darshon
        wrote on last edited by
        #3

        Hi Dave, Thanks for the explaination. :) I did try it without the domain but it still gave me the same 403 error. I'm quite puzzled, this should work. Could it be something wrong with my server? I can upload files through an ftp program, is there a way to upload a file through ftp within the 1.1 framework? ~D~

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups