473,804 Members | 3,383 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Address parameter in WebClient.Uploa dFile?

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

Hence my question, what is exactly the content of this
Upload_File.asp x? 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 4683
Play with this.....

Friend Function UploadFile(ByVa l SourceLocation As String, ByVal
DestinationLoca tion As String, ByRef ProgressBar As
System.Windows. Forms.ProgressB ar) 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
DestinationLoca tion.ToString.T rim <> "" Then
'To set Upload settings
Dim UploadRequest As System.Net.Http WebRequest =
CType(System.Ne t.WebRequest.Cr eate(New
Uri(Destination Location.ToStri ng.Trim)), System.Net.Http WebRequest)
UploadRequest.T imeout = 60000000
UploadRequest.M ethod = "PUT"
UploadRequest.C ontentLength = New
System.IO.FileI nfo(SourceLocat ion.ToString.Tr im).Length
FileSize = UploadRequest.C ontentLength.To String.Trim
'To set Upload Stream settings
Dim SourceStream As New
System.IO.FileS tream(SourceLoc ation.ToString. Trim, System.IO.FileM ode.Open,
System.IO.FileA ccess.Read, System.IO.FileS hare.ReadWrite)
Dim RequestStream As System.IO.Strea m =
UploadRequest.G etRequestStream ()
Dim Buffer(4095) As Byte
Dim Position As Integer = 0, ivlLoop As Integer = 0,
CurLocation As Integer = 0
Position = SourceStream.Re ad(Buffer, 0, Buffer.Length)
ProgressBar.Vis ible = True
ProgressBar.Val ue = 0
ProgressBar.Max imum = 100
While Position <> 0
RequestStream.W rite(Buffer, 0, Position)
Position = SourceStream.Re ad(Buffer, 0, Buffer.Length)
CurLocation += Position
ProgressBar.Val ue = CInt((CurLocati on / FileSize) * 100)
ProgressBar.Ref resh()
End While
Dim WebResponse As System.Net.Http WebResponse =
CType(UploadReq uest.GetRespons e(), System.Net.Http WebResponse)
Dim ResponseReader As New
System.IO.Strea mReader(WebResp onse.GetRespons eStream())
Response = ResponseReader. ReadToEnd()
UploadFile = True
RequestStream.C lose()
UploadRequest = Nothing
SourceStream = Nothing
RequestStream = Nothing
WebResponse = Nothing
ResponseReader = Nothing
ElseIf SourceLocation. ToString.Trim = "" Then
MsgBox("Source Location is missing", "UploadFile ")
ElseIf DestinationLoca tion.ToString.T rim = "" Then
MsgBox("Destina tion Location is missing", "UploadFile ")
End If
Catch ex As Exception
MsgBox(ex.ToStr ing)
Exit Function
End Try
'ProgressBar.Vi sible = 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.goo glegroups.com.. .
The 'Address' parameter in the WebClient.Uploa dFile usually comes in
the form of ie. http://server/Upload_File.aspx

Hence my question, what is exactly the content of this
Upload_File.asp x? 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 --> 'DestinationLoc ation' , 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 DestinationLoca tion --> '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"-"Administra tive Tools"-"Internet Information
Services".

Expand the tree to "COMPUTERNA ME"-"Web Sites"-"Default Web Site".

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

Select the "Home Directory" tab.

Click the "Configurat ion" 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\Syst em32\inetsrv\as p.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.goo glegroups.com.. .
Thanks for your help.

However, for the input parameter --> 'DestinationLoc ation' , 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 DestinationLoca tion --> '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.goo glegroups.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
1600
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. Looking through the documentation(ha) I noticed that webclient.uploadfile seemed to be the way forward. Although I can't find anything to tell me how I actually receive it.
0
1480
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 system. I don't want to use the input file method (as this will force the user to do unnessecary browsing and I know where the file will be: c:\test.txt for example). I am sure that I am just missing something simple. However, I can not figure...
2
2202
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 basically trying to upload a file from my .net app running on my local pc to a unix webserver (running iplanet). Just upload and store the file, thats it. I'm using webclient.uploadfile on the client side. Since its an iplanet webserver, I cant use...
1
5245
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 handle receipt of the files. Pertinent code for each is below. When I run the process locally in debug mode, everything works great ( VS.NET 2003 , ASP 1.1 ). When I run locally on the server, everything works great. When I try to remotely...
2
3968
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 webclient.UploadFile("http://127.0.0.1/ECSWebServices/UploadItem.aspx", "POST", "C:\Test.txt") and the file ends up looking like:
0
768
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 - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemNetWebClientClassUploadFileTopic1.asp. I creat a ReciveFile.aspx webpage with the content dercribed on this site and I use send the file with this code: WebClient web = new WebClient();...
5
10744
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); webClient.UploadFile("http://www.etfos.hr/~dhuis/test.txt", @"c:\test.txt"); i get an error "The remote server returned an error: (404) FIle not found" my web page is http://www.etfos.hr/~dhuis permissions are all enabled i tried with httpwebrequest class and...
6
4934
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 and the file is copied from the server to the server, rather than from the web client to the server. Please help!!!
5
5014
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 UploadGeneralFile(ByVal sURL as string,ByVal sFilename As String) Dim client As New System.Net.WebClient Dim sHTTPURL As String Dim req As New Uri(sURL) Dim respponse As Byte() sHTTPURL = req.Scheme() & "://" &...
0
9705
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9575
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10564
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10308
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10073
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9134
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6846
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5513
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3806
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.