Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual Basic
 How to: Upload a File
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Visual Basic Language Concepts 
How to: Upload a File in Visual Basic 

The My.Computer.Network.UploadFile Method can be used to upload a file and store it to a remote location. If the ShowUI parameter is set to True, a dialog box is displayed that shows the progress of the download and allows users to cancel the operation.

To upload a file

  • Use the UploadFile method to upload a file, specifying the source file's location and the target directory location as a string or URI (Uniform Resource Identifier).This example uploads the file Order.txt to http://www.cohowinery.com/uploads.aspx.

    Visual Basic
    My.Computer.Network.UploadFile( _
    "C:\My Documents\Order.txt", _
    "http://www.cohowinery.com/upload.aspx")

To upload a file and show the progress of the operation

  • Use the UploadFile method to upload a file, specifying the source file's location and the target directory location as a string or URI. This example uploads the file Order.txt to http://www.cohowinery.com/uploads.aspx without supplying a user name or password, shows the progress of the upload, and has a time-out interval of 500 milliseconds.

    Visual Basic
    My.Computer.Network.UploadFile( _
    "C:\My Documents\Order.txt", _
    "http://www.cohowinery.com/upload.aspx", "", "", True, 500)

To upload a file, supplying a user name and password

  • Use the UploadFile method to upload a file, specifying the source file's location and the target directory location as a string or URI, and specifying the user name and the password. This example uploads the file Order.txt to http://www.cohowinery.com/uploads.aspx, supplying the user name anonymous and a blank password.

    Visual Basic
    My.Computer.Network.UploadFile( _
    "C:\My Documents\Order.txt", _
    "http://www.cohowinery.com/upload.aspx", "anonymous", "")

Robust Programming

The following conditions may throw an exception:

See Also

Community Content   What is Community Content?
Add new content RSS  Annotations
Destination is unclear      egoer ... Red-Devile   |   Edit   |   Show History

I don't think this instruction is clear about the destination of the uploading.

It seems it has to be a file, but what type of file? must it be an aspx file? if so, any code required in the aspx?

And will the source file be uploaded into the folder where the aspx file is? it's not clear.

Would be helpful if there is a detailed example .

I Agree, Destination is unclear      frostfang ... Thomas Lee   |   Edit   |   Show History
I agree, this needs to be more descriptive and not rely on user knowledge. Please be more descriptive.
Just like uploading from a form      guru-meditation   |   Edit   |   Show History
Maybe not a full description is needed, but at least a reference to the ASP part would be nice. Of course it would depend on the servertype.

Here's a link for those who got Sun Microsystem's ChiliSoft installed on their server:
http://docs.sun.com/source/817-2514-10/Ch13_SpicePack68.html

Or look at this video showing you how to make a simple fileupload page:
http://www.asp.net/learn/videos/video-255.aspx
Tags What's this?: Add a tag
Flag as ContentBug
Nothing is Clear.      techsavy.ravi ... Stanley Roark   |   Edit   |   Show History
The UploadFile method has 10 variants and the progressbar is supported in one type only. Please clear it.

[tfl - 01 08 09] Hi - and thanks for your post. You should post questions like this to the MSDN Forums at http://forums.microsoft.com/msdn or the MSDN Newsgroups at http://www.microsoft.com/communities/newsgroups/en-us/. You are much more likely get a quicker response using the forums than through the Community Content. For specific help about:
Visual Studio :
http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public.vstudio%2C&
SQL Server :
http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public.sqlserver%2C&
.NET Framework :
http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public.dotnet.framework
PowerShell : http://groups.google.com/group/microsoft.public.windows.powershell/topics?pli=1
All Public : http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public%2C&
don't work with proxies      Cyrianox ... Thomas Lee   |   Edit   |   Show History
Hello


Why on the ***
My.Computer.Network.UploadFile
doesn't work with proxy ???


[tfl - 05 10 09] Hi - and thanks for your post. You should post questions like this to the MSDN Forums at http://forums.microsoft.com/msdn or the MSDN Newsgroups at http://www.microsoft.com/communities/newsgroups/en-us/. You are much more likely get a quicker response using the forums than through the Community Content. For specific help about:
Visual Studio :
http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public.vstudio%2C&
SQL Server :
http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public.sqlserver%2C&
.NET Framework :
http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public.dotnet.framework
PowerShell : http://groups.google.com/group/microsoft.public.windows.powershell/topics?pli=1
All Public : http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public%2C&
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker