VB2005 : Upload local file to a HTTP Site

  • Thread starter Screaming Eagles 101
  • Start date
S

Screaming Eagles 101

Hi,

I would like to upload a local file from the harddrive, f.i. a textfile on
C:\
to a Frontpage made website, for instance http://myIntranet/mySubdir

Is this possible ?

--
Filip
http://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
[It's nice to be important, but it's more important to be nice!]
----------------------------------------------------------------
 
K

kimiraikkonen

Hi,

I would like to upload a local file from the harddrive, f.i. a textfile on
C:\
to a Frontpage made website, for instancehttp://myIntranet/mySubdir

Is this possible ?

--
Filiphttp://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
[It's nice to be important, but it's more important to be nice!]
----------------------------------------------------------------

Yes, you can use WebClient class or directly UploadFile method in My
namespace as follows:

My.Computer.Network.UploadFile("c:\textfile.txt", _
"http://myIntranet/mySubdir/textfile.txt", "username", "password")

For other overloads of UploadFile method, see:
http://msdn.microsoft.com/en-us/library/dfkdh7eb.aspx
http://support.microsoft.com/kb/914355

Hope this helps,

Onur Güzel
 
S

Screaming Eagles 101

"kimiraikkonen" <[email protected]> schreef in bericht
Hi,

I would like to upload a local file from the harddrive, f.i. a textfile on
C:\
to a Frontpage made website, for instancehttp://myIntranet/mySubdir

Is this possible ?

--
Filiphttp://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
[It's nice to be important, but it's more important to be nice!]
----------------------------------------------------------------

Yes, you can use WebClient class or directly UploadFile method in My
namespace as follows:

My.Computer.Network.UploadFile("c:\textfile.txt", _
"http://myIntranet/mySubdir/textfile.txt", "username", "password")

For other overloads of UploadFile method, see:
http://msdn.microsoft.com/en-us/library/dfkdh7eb.aspx
http://support.microsoft.com/kb/914355

Hope this helps,

Onur Güzel
 
K

kimiraikkonen

"kimiraikkonen" <[email protected]> schreef in bericht
I would like to upload a local file from the harddrive, f.i. a textfileon
C:\
to a Frontpage made website, for instancehttp://myIntranet/mySubdir
Is this possible ?
--
Filiphttp://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
[It's nice to be important, but it's more important to be nice!]
----------------------------------------------------------------

Yes, you can use WebClient class or directly UploadFile method in My
namespace as follows:

My.Computer.Network.UploadFile("c:\textfile.txt", _
"http://myIntranet/mySubdir/textfile.txt", "username", "password")

For other overloads of UploadFile method, see:http://msdn.microsoft.com/en-us/library/dfkdh7eb.aspxhttp://support.microsoft.com/kb/914355

Hope this helps,

Onur Güzel

Then it's related to a server-side issue. Try to troubleshoot by
looking here:
http://www.checkupdown.com/status/E405.html

Thanks,

Onur Güzel
 
K

kimiraikkonen

"kimiraikkonen" <[email protected]> schreef in bericht
I would like to upload a local file from the harddrive, f.i. a textfileon
C:\
to a Frontpage made website, for instancehttp://myIntranet/mySubdir
Is this possible ?
--
Filiphttp://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
[It's nice to be important, but it's more important to be nice!]
----------------------------------------------------------------

Yes, you can use WebClient class or directly UploadFile method in My
namespace as follows:

My.Computer.Network.UploadFile("c:\textfile.txt", _
"http://myIntranet/mySubdir/textfile.txt", "username", "password")

For other overloads of UploadFile method, see:http://msdn.microsoft.com/en-us/library/dfkdh7eb.aspxhttp://support.microsoft.com/kb/914355

Hope this helps,

Onur Güzel

Hi,
As an additional and quick troubleshoot info, you can try to
initialize a NetworkCredential object and uploadfile using WebClient's
UploadFile method. You "may" need to define "PUT" method explictly to
make server accept incoming file as follows

Use that:

//////////////
Imports System.Net

Try
Using webclient As New WebClient
webclient.Credentials = _
New NetworkCredential("username", "mypassword")

webclient.UploadFile _
("http://myIntranet/mySubdir", "PUT", "c:\textfile.txt")
End Using

Catch ex As Exception

MsgBox(ex.Message)

End Try
\\\\\\\\\\\\\\\\\\\


Please let us know the result,

Onur Güzel
 
K

kimiraikkonen

"kimiraikkonen" <[email protected]> schreef in bericht
Hi,
I would like to upload a local file from the harddrive, f.i. a textfile on
C:\
to a Frontpage made website, for instancehttp://myIntranet/mySubdir
Is this possible ?
--
Filiphttp://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
[It's nice to be important, but it's more important to be nice!]
----------------------------------------------------------------
Yes, you can use WebClient class or directly UploadFile method in My
namespace as follows:
My.Computer.Network.UploadFile("c:\textfile.txt", _
"http://myIntranet/mySubdir/textfile.txt", "username", "password")
Hope this helps,
Onur Güzel

Hi,
As an additional and quick troubleshoot info, you can try to
initialize a NetworkCredential object and uploadfile using WebClient's
UploadFile method. You "may" need to define "PUT" method explictly to
make server accept incoming file as follows

Use that:

//////////////
Imports System.Net

Try
Using webclient As New WebClient
webclient.Credentials = _
New NetworkCredential("username", "mypassword")

webclient.UploadFile _
("http://myIntranet/mySubdir", "PUT", "c:\textfile.txt")
End Using

Catch ex As Exception

MsgBox(ex.Message)

End Try
\\\\\\\\\\\\\\\\\\\

Please let us know the result,

Onur Güzel

Quick correction for specifying exact destination file path followed
by file name:

' See UploadFile method's first parameter.

Try this finally:
//////////////
Imports System.Net

Try
Using webclient As New WebClient
webclient.Credentials = _
New NetworkCredential("username", "mypassword")

webclient.UploadFile _
("http://myIntranet/mySubdir/textfile.txt", "PUT", "c:\textfile.txt")
End Using

Catch ex As Exception

MsgBox(ex.Message)

End Try
\\\\\\\\\\\\\\\\\\\

Hope this finally helps,

Onur Güzel
 
S

Stanimir Stoyanov

Hello Filip,

You cannot upload files directly to a remote directory via HTTP without
implementing a service to take care of this. There are two solutions to this
problem that you might want to look into:

1) Set up an FTP server and an account with permissions to the target
directory. Then you can use an FTP client library to connect to your server
and upload the file. See http://www.codeproject.com/KB/IP/FtpClient.aspx for
a neat FTP client (with source code, C#).

2) Create a web service that is going to run at your site. It should have a
method accepting a file name and binary data to store in your folder. This
allows for better error handling and is a more advanced implementation than
using FTP. It relies on HTTP and is a software+service platform. After
writing and deploying your code you can add a Web Reference to your desktop
application and just call the method from the web service.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top