Login  
Search All Forums
Dart Home | PowerTCP Web Enterprise for ActiveX | Custom Development Reply | PowerTCP Web Enterprise for ActiveX Topics | Forums   
AuthorForum: PowerTCP Web Enterprise for ActiveX
Topic: Posting file to the parameter from stream
sg

From: Marysville, CA USA
Posts: 2
Member Since: 12/06/05
posted December 9, 2005 2:10 PM

Hi

I'm using evaluation version of the PowerTCP Web Enterprise Tool.
I tried to use following code in my application to post file
to the parameter of the destination page. It works OK. 

Dim files As New DartStreams
Dim file As New DartStream
file.FileName = "c:\temp\MUR.txt"
file.Ref = "upload_file"
files.Add file
WebASP1.Request.FilesToPost = files

Dim v As New HttpVariable
v.Name = "sendfile"
v.Value = "send"
WebASP1.Request.Variables.Add v

'Actual URL is different
WebASP1.Request.Url = "http://mydestserver/post.html"
WebASP1.Post

Is it possible to dump data from memory to the DartStream object instead of specifying FileName?
I tried to use Write method to assign data to the object and my posting failed.

FOr example:

Dim file As New DartStream
Dim cnt as Integer

cnt = file.Write(FromStringParameter)

file.Ref = "upload_file"

It looks like File control of the destination page requires actual file path?

Any suggestions?
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted December 12, 2005 8:51 AM

Yes, you should be able to write data to the stream and use it from memory. Perhaps you are not writing the correct data?
sg

From: Marysville, CA USA
Posts: 2
Member Since: 12/06/05
posted December 12, 2005 12:04 PM

Hi,
What do you mean correct data?

For example, I write following data and check the value using ReadString method:
Dim i As Integer = file.Write("Some test data")
file.Position = 0
Dim s As String = file.ReadString

It gives me the same value.

Then I checked the value of PostedFile and it is Nothing. Looks like <INPUT id="upload_file" name="upload_file" runat="server"> requires valid path and file? Am I missing something?

Below is an example of posting page:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  Dim files As New DartStreams
  Dim file As New DartStream

  Dim WebASP1 As WebASP

  Dim i As Integer = file.Write("Some test data")
  file.Position = 0
  Dim s As String = file.ReadString

  '''''file.FileName ="C:\Temp\MUR.txt"

  file.Ref = "upload_file"
  files.Add(file)
  WebASP1.Request.FilesToPost = files

  Dim v As New HttpVariable
  v.Name = "save_file"
  v.Value = "save"
  WebASP1.Request.Variables.Add(v)

  WebASP1.Request.Url = "http://localhost/Upload%20File/WebForm1.aspx"
  WebASP1.Post()

  TextBox1.Text = WebASP1.Response.StatusText
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Below is an example of destination page:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  If Not Me.upload_file.PostedFile Is Nothing Then
   Dim sPath As String = Server.MapPath(".") & "\files"

   Dim sFile As String = "test.txt"

   If IO.File.Exists(sPath & "\" & sFile) Then
    IO.File.Delete(sPath & "\" & sFile)
   End If

   upload_file.PostedFile.SaveAs(sPath & "\" & sFile)
  End If
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted December 13, 2005 12:00 PM

Sorry, but I am not really sure what's going on. Please contact support@dart.com to discuss alternate support options.
Reply | PowerTCP Web Enterprise for ActiveX Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX