|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
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. 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).Length 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.GetResponseStream()) 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 -- Show quoteHide quoteGet a powerful web, database, application, and email hosting with KJM Solutions http://www.kjmsolutions.com "linn" <ta***@ccn.com.sg> wrote in message news:1140516074.162529.178140@z14g2000cwz.googlegroups.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. > 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. 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.) -- Show quoteHide quoteGet a powerful web, database, application, and email hosting with KJM Solutions http://www.kjmsolutions.com "linn" <ta***@ccn.com.sg> wrote in message news:1140597631.395449.292120@g44g2000cwa.googlegroups.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. > Thanks.
In fact, I have done all you have mentioned however it still fails. ;o( 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. -- Show quoteHide quoteGet a powerful web, database, application, and email hosting with KJM Solutions http://www.kjmsolutions.com "linn" <ta***@ccn.com.sg> wrote in message news:1140661427.977946.179550@z14g2000cwz.googlegroups.com... > Thanks. > > In fact, I have done all you have mentioned however it still fails. ;o( >
Program flow control
Current Recordset does not support updating - HELP needed! Read a file, knowing only a part of its name Windows Service stopped working Unable to open file remotely Which Database type to use? system.runtime.interopservices.COMException Simple Binding with Textbox Control mshflexgrid Problem Countdown Timer |
|||||||||||||||||||||||