473,320 Members | 2,189 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Address parameter in WebClient.UploadFile?

The 'Address' parameter in the WebClient.UploadFile usually comes in
the form of ie. http://server/Upload_File.aspx

Hence my question, what is exactly the content of this
Upload_File.aspx? Am i supposed to create this file with some specific
codes?

Can't seems to get this method working for me in framework 2.0..

Thanks for any help.

Feb 21 '06 #1
5 4656
Play with this.....

Friend Function UploadFile(ByVal SourceLocation As String, ByVal
DestinationLocation As String, ByRef ProgressBar As
System.Windows.Forms.ProgressBar) As Boolean
Dim StartTime As DateTime = DateTime.Now()
Dim Response As String = Nothing, FileSize As Double = 0
Try
UploadFile = False
If SourceLocation.ToString.Trim <> "" And
DestinationLocation.ToString.Trim <> "" Then
'To set Upload settings
Dim UploadRequest As System.Net.HttpWebRequest =
CType(System.Net.WebRequest.Create(New
Uri(DestinationLocation.ToString.Trim)), System.Net.HttpWebRequest)
UploadRequest.Timeout = 60000000
UploadRequest.Method = "PUT"
UploadRequest.ContentLength = New
System.IO.FileInfo(SourceLocation.ToString.Trim).L ength
FileSize = UploadRequest.ContentLength.ToString.Trim
'To set Upload Stream settings
Dim SourceStream As New
System.IO.FileStream(SourceLocation.ToString.Trim, System.IO.FileMode.Open,
System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite)
Dim RequestStream As System.IO.Stream =
UploadRequest.GetRequestStream()
Dim Buffer(4095) As Byte
Dim Position As Integer = 0, ivlLoop As Integer = 0,
CurLocation As Integer = 0
Position = SourceStream.Read(Buffer, 0, Buffer.Length)
ProgressBar.Visible = True
ProgressBar.Value = 0
ProgressBar.Maximum = 100
While Position <> 0
RequestStream.Write(Buffer, 0, Position)
Position = SourceStream.Read(Buffer, 0, Buffer.Length)
CurLocation += Position
ProgressBar.Value = CInt((CurLocation / FileSize) * 100)
ProgressBar.Refresh()
End While
Dim WebResponse As System.Net.HttpWebResponse =
CType(UploadRequest.GetResponse(), System.Net.HttpWebResponse)
Dim ResponseReader As New
System.IO.StreamReader(WebResponse.GetResponseStre am())
Response = ResponseReader.ReadToEnd()
UploadFile = True
RequestStream.Close()
UploadRequest = Nothing
SourceStream = Nothing
RequestStream = Nothing
WebResponse = Nothing
ResponseReader = Nothing
ElseIf SourceLocation.ToString.Trim = "" Then
MsgBox("Source Location is missing", "UploadFile")
ElseIf DestinationLocation.ToString.Trim = "" Then
MsgBox("Destination Location is missing", "UploadFile")
End If
Catch ex As Exception
MsgBox(ex.ToString)
Exit Function
End Try
'ProgressBar.Visible = False
End Function

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"linn" <ta***@ccn.com.sg> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
The 'Address' parameter in the WebClient.UploadFile usually comes in
the form of ie. http://server/Upload_File.aspx

Hence my question, what is exactly the content of this
Upload_File.aspx? Am i supposed to create this file with some specific
codes?

Can't seems to get this method working for me in framework 2.0..

Thanks for any help.

Feb 21 '06 #2
Thanks for your help.

However, for the input parameter --> 'DestinationLocation' , I have
supplied something like 'http://127.0.0.1/temp/' and I received a
remote server returned an error: 405 Method not allowed.

Is my DestinationLocation --> 'http://127.0.0.1/temp/' wrongly
specified or could it be due to some other reason.

Appreciate your advice.

Thanks.

Feb 22 '06 #3
Try using your actual IP address instead.

Here are some steps to see if IIS is configured properly.

Go to "Control Panel"-"Administrative Tools"-"Internet Information
Services".

Expand the tree to "COMPUTERNAME"-"Web Sites"-"Default Web Site".

Right-click on "Default Web Site" and select "Properties".

Select the "Home Directory" tab.

Click the "Configuration" button.

From the "Mappings" tab, select the "Add" button.

Click the "Browse..." button, choose "Dynamic Link Libraries *.dll" from the
"Files of Type" dropdown, and select c:\WINDOWS\System32\inetsrv\asp.dll.

Type ".html" (without quotes) in the "Extension" box.

Select the "Limit to:" radio button, and type in "GET, POST" (without
quotes) in the box next to it.

Click the "OK" button and close all the dialogs. (If the "OK" button is
greyed out, then make sure all the entries are correct and try clicking in
the file name box.)

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"linn" <ta***@ccn.com.sg> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Thanks for your help.

However, for the input parameter --> 'DestinationLocation' , I have
supplied something like 'http://127.0.0.1/temp/' and I received a
remote server returned an error: 405 Method not allowed.

Is my DestinationLocation --> 'http://127.0.0.1/temp/' wrongly
specified or could it be due to some other reason.

Appreciate your advice.

Thanks.

Feb 22 '06 #4
Thanks.

In fact, I have done all you have mentioned however it still fails. ;o(

Feb 23 '06 #5
OK. Contact me on my site (my email link is there) and I will arrange a app
sharing with you to see if we cna get to the bottom of this.

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"linn" <ta***@ccn.com.sg> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Thanks.

In fact, I have done all you have mentioned however it still fails. ;o(

Feb 23 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: belfast neil | last post by:
Hey guys, I've seen alot of questions out there about webclient.uploadfile, my question is slightly different.......... I have a rich client app and I want to upload files to a server....
0
by: David W | last post by:
I am trying to upload a file from a user's system to my web server. I found code using the WebClient.UploadFile method. However, the uploaded file is from the server's hard drive not the user's...
2
by: marfi95 | last post by:
Hello all. I'm not sure if this is the correct place to post this, but if not please let me know. This is my situation. I have a simple problem, but am having problems doing this. I'm...
1
by: Phillip N Rounds | last post by:
I'm having problems using the WebClient.UploadFile() command. I have MySender.ASPX which is supposed to upload two files to the server. There is also ConsumeFileUpload.aspx which is intended to...
2
by: UJ | last post by:
I'm trying to upload stuff using the UploadFile from WebClient and I've noticed that it adds header and footers to the stream. Is there any way to get rid of that automatically? I'm using...
0
by: Mihaly | last post by:
I have a WinForms 1.1 application and I want to post some files on the webserver, using WebClient.UploadFile() method. I try the solution from MSDN site -...
5
by: Svinja | last post by:
Hi, i am using WebClient.UploadFile to upload a file on my web page, code: WebClient webClient = new WebClient(); webClient.Credentials = new NetworkCredential(userName, pass);...
6
by: =?Utf-8?B?U2NvdHQgVHJpY2s=?= | last post by:
I followed the instructions from MSDN for Webclient UploadFile and I get an error: Could not find file 'C:\testfile.xls'. If I add the file (c:\testfile.xls) to the server I do not get the error...
5
by: benmess | last post by:
This code snippet works fine on a localhost because the file you upload resides on the host machine (where FileServer.aspx is a new page invoked from the UploadFile call) function...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.