How to upload a file on website using vb.net code

i want to upload file without click on this button… is there any way to upload the file…

i am already using this code to download the file:

Using wc As New System.Net.WebClient()
wc.DownloadFile(Url,Path)
End Using

i am not getting how to upload the file using this types of codes

Hello @Vinit_Mhatre!

It seems that you have trouble getting an answer to your question in the first 24 hours.
Let us give you a few hints and helpful links.

First, make sure you browsed through our Forum FAQ Beginner’s Guide. It will teach you what should be included in your topic.

You can check out some of our resources directly, see below:

  1. Always search first. It is the best way to quickly find your answer. Check out the image icon for that.
    Clicking the options button will let you set more specific topic search filters, i.e. only the ones with a solution.

  2. Topic that contains most common solutions with example project files can be found here.

  3. Read our official documentation where you can find a lot of information and instructions about each of our products:

  4. Watch the videos on our official YouTube channel for more visual tutorials.

  5. Meet us and our users on our Community Slack and ask your question there.

Hopefully this will let you easily find the solution/information you need. Once you have it, we would be happy if you could share your findings here and mark it as a solution. This will help other users find it in the future.

Thank you for helping us build our UiPath Community!

Cheers from your friendly
Forum_Staff

I am also trying the same thing . If you found any solution please do inform Me. I have also downloaded file using Invoke code. But looking for the same to upload file.

Hi @Kevin_Palathuruthy
Try this code to download file from website.

Dim client As New WebClient()
Dim fileUrl As String = “http://www.example.com/files/MyFile.txt
Dim filePath As String = “C:\MyFile.txt”

client.Headers.Add(“User-Agent”, “MyCustomUserAgent”)
client.DownloadFile(fileUrl, “GET”, filePath)

Is there similar Code instead of downloading I need to upload to a section which shows upload documents.

Please inform the same below

Hi @kevin_joy
Try this code for upload the documents in website. This is general code; based on your requirements, you can customise it.

VB.net Code:

’ Define the path to the file you want to upload
Dim filePath As String = “C:\my-file.txt”

’ Create a WebClient object
Dim client As New System.Net.WebClient()

’ Set the request URL and method
Dim url As String = “http://www.example.com/upload.php
Dim method As String = “POST”

’ Set the request headers
client.Headers.Add(“Content-Type”, “application/octet-stream”)

’ Read the contents of the file
Dim fileContents() As Byte = System.IO.File.ReadAllBytes(filePath)

’ Upload the file
Dim response As Byte() = client.UploadData(url, method, fileContents)

Thanks for this detailed explanation.