Kdyer
(KiX Supporter)
2002-11-27 11:54 PM
FTP via InetCtls.Inet.1

Appears to work..
But..

Cannot do a -

$ftpo.execute , $dirchg

For example..
code:
 BREAK ON 
CLS
;InetCtls.Inet.1
;Msinet.ocx

; - http://cwashington.netreach.net/depo/view.asp?Index=419&ScriptType=vbscript
; - http://www.bridgeport.edu/~mahmood/cs555_utils.doc
;;dim $objArgs

$ftpo = CreateObject("InetCtls.Inet.1")
IF @error <> '0'
?@error + " encountered - leaving now, could not find InetCtls.Inet.1"
SLEEP 3
EXIT 2
ENDIF
?"Looks good"
SLEEP 1
$url = "ftp://www.yoururl.com"
$rdir = "remotedir"
$user = "user"
$pass = "yourpass"
$slfile = "C:\cr.dbf"
$ftpo.url = $url
$ftpo.username = $user
$ftpo.password = $pass
?"Connecting..."
$dirchg = "CD " + $rdir
$ftpo.execute chr(44) $dirchg
;$ftpo.execute , $dirchg ; -- KiXtart does not like this

$tst = $ftpo.execute chr(44) "dir"
?$tst
get $
$sSendfl = "SEND " + $slfile
$ftpo.Execute chr(44) $sSendfl
?"Closing"
$ftpo.execute chr(44) "Close"
?"Done!"
$fso = nothing
$ftpo = nothing
SLEEP 2

Thanks,

Kent


Chris S.
(MM club member)
2002-11-28 12:31 AM
Re: FTP via InetCtls.Inet.1

Did you try putting it in parens ()?

LonkeroAdministrator
(KiX Master Guru)
2002-11-28 12:36 AM
Re: FTP via InetCtls.Inet.1

this I think is the basic problem of ppl trying to translate from vb...

kent, writing this for what?

anyway, like chris said, it looks like it should be:
code:
$ftpo.execute( chr(44)+$dirchg)



LonkeroAdministrator
(KiX Master Guru)
2002-11-28 12:55 AM
Re: FTP via InetCtls.Inet.1

mmm, checked from typelib, there seems to be more to it:
quote:
Sub Execute ([ByVal URL], [ByVal Operation], [ByVal InputData], [ByVal InputHdrs])


Kdyer
(KiX Supporter)
2002-11-28 01:01 AM
Re: FTP via InetCtls.Inet.1

Jooel,

This is more of a "proof of concept" or experiment than anything else. Most people will not have "InetCtls.Inet.1" available to them as they do not have Visual Studio installed.

Kent


LonkeroAdministrator
(KiX Master Guru)
2002-11-28 01:05 AM
Re: FTP via InetCtls.Inet.1

well, something to learn, didn't know it's from VS [Eek!]

Kdyer
(KiX Supporter)
2002-11-28 06:18 AM
Re: FTP via InetCtls.Inet.1

Code is too weird...

I think I will dig into XML-related area for this..

I know you can use the FTP program M$ gives you, but I was wanting to play with this under COM.

Kent


Bryce
(KiX Supporter)
2002-11-28 06:36 AM
Re: FTP via InetCtls.Inet.1

CuteFTP has a COM interface.

Kdyer
(KiX Supporter)
2002-11-29 07:40 AM
Re: FTP via InetCtls.Inet.1

Nice idea..

But too weird and not everybody has the required objects to do this.

Think I will work with Howard's DLL. Win32Admin.DLL updated

I was going to go with Internet Data Transfer Library for MS-Access as what the target audience will be using it for transferring a Database.. But, Howard's code usage is much simpler.

This was originally prompted by Looking for a good FTP Client.

code:
break on
$db = "N:\usersdatabase\users.mdb"
; -- Step one - Determine where MS-Access installed for the executable
$Access = READVALUE("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\MSACCESS.EXE","")
; -- Step two - Compact the database each time before transfer as there will be alot of inserts done on it
; -- Developer's Note: MS-Access is notorious for "bloat" when inserts are done and/records removed
RUN $Access + " " + $db + "//compact"
SLEEP 1
; -- Step three - Start the FTP Process
$Win32Admin = createobject("Win32Admin")
; Method FTP($RemoteServer, $Account, $Password, $Mode, $LocalDir, $RemoteDir, $Action, $Filename)
; $Mode -> [ascii|binary]
; $Action -> [get|put|size]
;
; Performs the specified FTP operation.
; Be sure to double the "@" in the password or email address if used for anonymous logons.

$RemoteServer = 'someserver.com'
$Account = 'userid'
$Password = 'password'
$Mode = 'binary'
$LocalDir = 'n:\usersdatabase'
$RemoteDir = 'database'
$Action = 'put'
$Filename = 'users.mdb'

IF $Win32Admin.FTP( $RemoteServer, $Account, $Password, $Mode, $LocalDir, $RemoteDir, $Action, $Filename)
? ? "FTP successful"
?
else
? ? "FTP Failed! @serror"
?
endif

Thanks,

Kent


LonkeroAdministrator
(KiX Master Guru)
2002-11-29 08:03 AM
Re: FTP via InetCtls.Inet.1

and I thought you were just playing...
doesn't IE have way for this too.


Kdyer
(KiX Supporter)
2002-11-29 08:20 AM
Re: FTP via InetCtls.Inet.1

I may play as time permits.

Isn't there something in xmlhttp or maybe xmlftp?

I did see - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsmart02/html/sa02a1.asp and downloaded the example, but still uses FTP.EXE.

Hmmm maybe something with wininet?

Kent


LonkeroAdministrator
(KiX Master Guru)
2002-11-29 10:21 AM
Re: FTP via InetCtls.Inet.1

mmm... is that scriptable?

LonkeroAdministrator
(KiX Master Guru)
2002-11-29 10:41 AM
Re: FTP via InetCtls.Inet.1

xmlhttp object should be able, but how can kixtart manage that stream coming in?

it can't write it to file...

let me see if we have such an udf...


Kdyer
(KiX Supporter)
2002-11-30 07:20 PM
Re: FTP via InetCtls.Inet.1

Jooel,

I think I found it -

http://groups.google.com/groups?q=xmlhttp+ftp&hl=en&lr=&ie=UTF-8&selm=%23ZHFbJr3BHA.2488%40tkmsftngp04&rnum=2

Thanks,

Kent


Kdyer
(KiX Supporter)
2002-11-30 07:28 PM
Re: FTP via InetCtls.Inet.1

Started to do a conversion..

code:
 break on
; --- http://groups.google.com/groups?q=xmlhttp+ftp&hl=en&lr=&ie=UTF-8&selm=%23ZHFbJr3BHA.2488%40tkmsftngp04&rnum=2
$sxmldata = GetXML("ftp://ftp.microsoft.com/bussys/readme.txt","","")
?$sxmldata

FUNCTION GetXML($surl,$susr,$spasswd)
; Create an xmlhttp object:
DIM $oxml
$oxml = CreateObject("Microsoft.XMLHTTP")
;Opens the connection to the remote server.
;rtn = xml.Open((B))
$oxml.open "GET" chr(44) $surl chr(44) $false chr(44) $susr chr(44) $spasswd
; Actually Sends the request and returns the data:
$oxml.send
DO
WHILE $oxml.readystate<>4
SLEEP 10
LOOP
UNTIL
$getxml = $oxml.responsetext
ENDFUNCTION

Kent


LonkeroAdministrator
(KiX Master Guru)
2002-11-30 07:30 PM
Re: FTP via InetCtls.Inet.1

well, that is the text way but how to get the streams...
this neither gives you the real text as it converts it. responsebody is returned as-is
and btw, with kix you can just do:
code:
$net=createobject("microsoft.xmlhttp")
$net.open("GET",$address,not 1)
$net.send
$THEFILE=$net.responsebody

to get the binary stuff you would need to change the last line to:
$THEFILE=$net.responsestream

but that we cannot process.


LonkeroAdministrator
(KiX Master Guru)
2002-11-30 07:32 PM
Re: FTP via InetCtls.Inet.1

oh, this is btw the object checker uses

Kdyer
(KiX Supporter)
2002-11-30 08:10 PM
Re: FTP via InetCtls.Inet.1

Jooel,

I think this may shed some light on the Binary piece..

http://groups.google.com/groups?q=GetXML+binary&hl=en&lr=&ie=UTF-8&selm=3ddb8491%240%2411028%24afc38c87%40news.optusnet.com.au&rnum=5

Kent


LonkeroAdministrator
(KiX Master Guru)
2002-11-30 08:11 PM
Re: FTP via InetCtls.Inet.1

thanks, back in 5 with code...

LonkeroAdministrator
(KiX Master Guru)
2002-11-30 08:15 PM
Re: FTP via InetCtls.Inet.1

then need a ftp site to test on...

LonkeroAdministrator
(KiX Master Guru)
2002-11-30 08:37 PM
Re: FTP via InetCtls.Inet.1

now you can help me.
can't get this bloody thing to do nothing!
kix does not even show me the errors.

code:
FTPget("ftp://ftp.cpan.org/pub/CPAN/src/perl-5.8.0.tar.gz",@scriptdir+"\perl-5.8.0.tar.gz")
if @error "Error: " @error else "success" endif
get $

Function FTPget($sURL, $sTargetFile)
Dim $oFTP, $oStream
$oFTP = CreateObject("MSXML2.ServerXMLHTTP")
if @error exit cerror endif
$oStream = CreateObject("ADODB.Stream")
if @error exit cerror endif

$oFTP.Open("GET", $sURL, not 1)
if @error exit cerror endif
$oFTP.Send

$oStream.Type = 1
$oStream.Mode = 3
$oStream.open
$oStream.Write($oFTP.responseBody)
if @error exit cerror endif
$oStream.SaveToFile($sTargetFile, 2)
if @error exit cerror endif
$oStream.Close
EndFunction

function Cerror(optional $)
$Cerror = @error
$=0+$
$Cerror=dectohex($Cerror)
$Cerror=right($Cerror,4)
$_nul=execute("$$Cerror=&$Cerror")
if $ _translate($Cerror)
$_nul=execute("$$Cerror='@serror'")
endif
endfunction
function _translate($)
exit $
endfunction



LonkeroAdministrator
(KiX Master Guru)
2002-11-30 08:40 PM
Re: FTP via InetCtls.Inet.1

btw, I know that we should probably use timeout value with that object but as long as there is something wrong in such way that I can see nothing (kix just closes without error), there is no use even trying to implement anything more...

LonkeroAdministrator
(KiX Master Guru)
2002-11-30 09:08 PM
Re: FTP via InetCtls.Inet.1

thanks kent, will post into UDF if you don't mind.
final code which works without xmlhttp-sdk:
code:
Function FTPget($sURL, $sTargetFile)
Dim $oFTP, $oStream
$oFTP = CreateObject("Microsoft.XMLHTTP")
if @error ?"ftp init:" cerror endif
$oStream = CreateObject("ADODB.Stream")
if @error ?"ado init:" cerror endif

$oFTP.Open("GET", $sURL, not 1)
if @error ?"ftp open:" cerror endif
$oFTP.Send

$oStream.Type = 1
$oStream.Mode = 3
$oStream.open
$oStream.Write($oFTP.responseBody)
if @error ?"ado write:" cerror endif
$oStream.SaveToFile($sTargetFile, 2)
if @error ?"ado save:" cerror endif
$oStream.Close
EndFunction



LonkeroAdministrator
(KiX Master Guru)
2002-11-30 09:40 PM
Re: FTP via InetCtls.Inet.1

is this ok?
http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=12;t=000312


Kdyer
(KiX Supporter)
2002-12-01 07:32 AM
Re: FTP via InetCtls.Inet.1

I would like to see authentication methods implemented..

That is a UserID and password..

Not only a FTPGet but FTPPut too.

Kent

[ 01. December 2002, 07:33: Message edited by: kdyer ]


LonkeroAdministrator
(KiX Master Guru)
2002-12-01 07:38 AM
Re: FTP via InetCtls.Inet.1

eh, put definitely needs auth but don't have any place to test for auth connections.
neither put.
would need sftp for that.


Kdyer
(KiX Supporter)
2002-12-02 08:01 AM
Re: FTP via InetCtls.Inet.1

Jooel,

It seems that I am really close with this..

I have tried encoding with image/jpeg too.

code:
 BREAK ON
; -- http://support.microsoft.com/default.aspx?scid=kb;EN-US;q298108
; -- http://support.microsoft.com/default.aspx?scid=kb;EN-US;q296713
$user = "kdyer"
$password = "password"
$address = "ftp://ftpsite"
$rdir = "/kdyer"
$file = "C:\untitled1.jpg"
$ftpobj = CreateObject("microsoft.xmlhttp")
IF @error <> 0
?@error
SLEEP 2
EXIT 1
ENDIF

$ftpobj.open("PUT", $address, FALSE, $user,$password)

IF $file <> ""
; -- check to insure that you have the right encoding
;application/x-www-form-urlencoded
;image/gif
;image/x-xbitmap
;image/jpeg
;image/pjpeg;
;application/vnd.ms-powerpoint;
;application/vnd.ms-excel
;application/msword
;*/*
$ftpobj.setrequestheader = "Content-Type", "*/*"
$ftpobj.send $file
ENDIF
$ftpobj = 0

Thanks,

Kent


LonkeroAdministrator
(KiX Master Guru)
2002-12-02 08:40 AM
Re: FTP via InetCtls.Inet.1

does the put work?
I thought that it only had get and post.
(like in checkers load.udf) [Wink]


LonkeroAdministrator
(KiX Master Guru)
2002-12-02 11:29 PM
Re: FTP via InetCtls.Inet.1

kent, any update?

I've been thinking of using http-object as framework for kixtart-sockets so any update on these are helpfull.


Kdyer
(KiX Supporter)
2002-12-03 02:24 AM
Re: FTP via InetCtls.Inet.1

Will look into this app this evening. Was busy trying to sort out a Citrix Printing issue today.

Kent


LonkeroAdministrator
(KiX Master Guru)
2002-12-03 02:25 AM
Re: FTP via InetCtls.Inet.1

huh, thought america had received nuclear blast or something...
so silent...


Les
(KiX Master)
2002-12-03 02:38 AM
Re: FTP via InetCtls.Inet.1

More like nuclear winter here with -31°C low tonight. {brrr}

LonkeroAdministrator
(KiX Master Guru)
2002-12-03 02:41 AM
Re: FTP via InetCtls.Inet.1

hehee.
http://www.fmi.fi/saa/paikalli.html?neito=1&kunta=Jyväskylä

and it's night time, meaning that most likely day is warmer [Big Grin]

anyway, that should be a reason to post more.


Les
(KiX Master)
2002-12-03 02:48 AM
Re: FTP via InetCtls.Inet.1

Jooel,
Busy carrying armloads of firewood to keep the homefire burning.

Kent,
Have you tried the 6.3x client with the new universal printer?


Kdyer
(KiX Supporter)
2002-12-03 02:53 AM
Re: FTP via InetCtls.Inet.1

Les,

We have the new client.. It is not that we cannot print, but the Admin that put the Application on the server, you cannot print Management Reports from it.

Kent


LonkeroAdministrator
(KiX Master Guru)
2002-12-03 02:55 AM
Re: FTP via InetCtls.Inet.1

stupid admins, I never seen one that has any brains left [Wink]

Kdyer
(KiX Supporter)
2002-12-03 09:27 AM
Re: FTP via InetCtls.Inet.1

{Edit - Corrected the GET/POST}
Well..

I can get it to draw a pretty html doc, but not post. [Confused]

code:
 BREAK ON
;;Dim $binaryContent
; -- http://support.microsoft.com/default.aspx?scid=kb;EN-US;q298108
; -- http://support.microsoft.com/default.aspx?scid=kb;EN-US;q296713
; -- http://support.microsoft.com/support/kb/articles/Q237/9/06.ASP
; -- http://www.bibit.com/asp_example_source_documentation.html
$user = "uid"
$password = "pass"
$address = "ftp://site.com/kdyer"
$rdir = "/kdyer"
$file = "C:\untitled1.jpg"
$ftpobj = CreateObject("microsoft.xmlhttp")
IF @error <> 0
?@error
SLEEP 2
EXIT 1
ENDIF

;;$ftpobj.open("POST", $address, FALSE, $user, $password)

; -- http://www.planet-source-code.com/xq/ASP/txtCodeId.5746/lngWId.1/qx/vb/scripts/ShowCode.htm
$ftpobj.open("GET",$address,not 1)
$ftpobj.send
$strCookie = $ftpobj.getResponseHeader("set-cookie")
$strCookie = Left($strCookie, InStr($strCookie, ";") - 1)
;better check the feedback
$testresl = $ftpobj.responseText
?$testresl
;do the actual send
$ftpobj.open("POST", $address+$rdir, not 1, $user, $password)
$ftpobj.setRequestHeader("Cookie", $strCookie)
;we need to do it a second time due to K
; B article Q234486.
$ftpobj.setRequestHeader("Cookie", $strCookie)
$ftpobj.setrequestheader("MIME-Version", "1.0")
$ftpobj.setRequestHeader("Depth", "0")
; -- Think we need to do something like
; -- http://support.microsoft.com/default.aspx?scid=kb;en-us;Q298108
; -- Re. Lvarbin
;$ftpobj.send($file) ; -- If we comment out this line we can see the site
$ftpobj.send $file
$testres = $ftpobj.responseText ; -- this actually draws the FTP Site :)
?$testres

?"Press a key"
get $

I am pretty trashed.. Time for rest..

Added in a note about Lvarbin: where I think we need to convert to binary data before posting.

Hmmm..

Kent

[ 03. December 2002, 09:39: Message edited by: kdyer ]


LonkeroAdministrator
(KiX Master Guru)
2002-12-03 09:33 AM
Re: FTP via InetCtls.Inet.1

for correct syntax you should check load.udf

Kdyer
(KiX Supporter)
2002-12-03 09:40 AM
Re: FTP via InetCtls.Inet.1

Fixed..

Kent


Kdyer
(KiX Supporter)
2002-12-04 04:50 PM
Re: FTP via InetCtls.Inet.1

With the following code, I am getting the following error message:
quote:

-2147352567 Binary err

Here is the code..

code:
BREAK ON
Dim $oStream
; -- http://support.microsoft.com/default.aspx?scid=kb;EN-US;q298108
; -- http://support.microsoft.com/default.aspx?scid=kb;EN-US;q296713
; -- http://support.microsoft.com/support/kb/articles/Q237/9/06.ASP
; -- http://www.bibit.com/asp_example_source_documentation.html
$address = "site.com"
$rdir = "/kdyer/kdyer"
$user = "kdyer"
$password = "pass"
$file = "C:\cr.dbf"
$ftpobj = CreateObject("microsoft.xmlhttp")
$oStream = CreateObject("ADODB.Stream")
; -- Convert to binary
$oStream.Type = 1 ; adTypeBinary
;;$oStream.Type = 2 ; adTypeText
;$bFileData = $oStream.LoadFromFile($file)
$oStream.LoadFromFile($file)
$oStream.open
IF @error <> 0
?@error " Binary err"
get $
EXIT 1
ENDIF

;;$ftpobj.open("POST", $address, FALSE, $user, $password)

; -- http://www.planet-source-code.com/xq/ASP/txtCodeId.5746/lngWId.1/qx/vb/scripts/ShowCode.htm
$ftpobj.open("GET",$address,not 1)
$ftpobj.send
$strCookie = $ftpobj.getResponseHeader("set-cookie")
$strCookie = Left($strCookie, InStr($strCookie, ";") - 1)
;better check the feedback
$testresl = $ftpobj.responseText
?$testresl
;do the actual send
$ftpobj.open("POST", $address+$rdir, not 1, $user, $password)
$ftpobj.setRequestHeader("Cookie", $strCookie)
;we need to do it a second time due to K
; B article Q234486.
$ftpobj.setRequestHeader("Cookie", $strCookie)
$ftpobj.setrequestheader("MIME-Version", "1.0")
$ftpobj.setRequestHeader("Depth", "0")
; -- Think we need to do something like
; -- http://support.microsoft.com/default.aspx?scid=kb;en-us;Q298108
; -- Re. Lvarbin
;$ftpobj.send($file) ; -- If we comment out this line we can see the site
$ftpobj.send($bFileData)
$testres = $ftpobj.responseText ; -- this actually draws the FTP Site :)
?$testres

?"Press a key"
get $

Thinking some coversion may need to be done..

code:
;ref - http://cwashington.netreach.net/depo/view.asp?Index=622&ScriptType=vbscript
Function decimalToBinary($intDecimal)
$strBinary = ""
$intDecimal = cInt($intDecimal)
While ($intDecimal > 1)
$lngNumber1 = $intDecimal / 2
$lngNumber2 = Fix($lngNumber1)
If ($lngNumber1 > $lngNumber2)
$strDigit = "1"
Else
$strDigit = "0"
EndIf
$strBinary = $strDigit + $strBinary
$intDecimal = Fix($intDecimal / 2)
Loop
$strBinary = "1" & $strBinary
While Len($strBinary) < 8
$strBinary = "0" + $strBinary
Loop
$binString = $strBinary
EndFunction

Any insights?

Kent


LonkeroAdministrator
(KiX Master Guru)
2002-12-04 05:06 PM
Re: FTP via InetCtls.Inet.1

eh, so ado is not working?
thought you were the one from us who knows that part [Wink]


Kdyer
(KiX Supporter)
2002-12-05 06:57 AM
Re: FTP via InetCtls.Inet.1

Did some more digging..

Found some Micheal Harris posts on Google (old Deja) Groups.

Stream.Write Buffer

Is what we need to be focusing on-

Stream Object

Thanks,

Kent

[ 05. December 2002, 07:01: Message edited by: kdyer ]


LonkeroAdministrator
(KiX Master Guru)
2002-12-05 07:01 AM
Re: FTP via InetCtls.Inet.1

steam?
as in sauna?


Kdyer
(KiX Supporter)
2002-12-05 07:02 AM
Re: FTP via InetCtls.Inet.1

Doh!

Yeah.. I could use one of those right now!

Wanna send me one?

Seriously, it is Stream.

Kent


LonkeroAdministrator
(KiX Master Guru)
2002-12-05 07:05 AM
Re: FTP via InetCtls.Inet.1

mmm, dunno. responsebody should do that...

mm... yep, stream goes for binary.
but when reading, responsebody handles both, binary and text... auto-mode may I say...


LonkeroAdministrator
(KiX Master Guru)
2002-12-05 07:06 AM
Re: FTP via InetCtls.Inet.1

I'll dig up more that ADO stuff once I get to work.
been trying to leave for 3 hours unsuccessfully.


Kdyer
(KiX Supporter)
2002-12-06 05:17 PM
Re: FTP via InetCtls.Inet.1

What we appear to need is a method that converts to binary for file transfer.

Neither of these methods work:

Method (1) conversion to Binary using multi-part form data
code:
if WinHTTPPostRequest("ftp://ftpsite/kdyer/kdyer", "c:\cr.dbf","kdyer","pw")
?"error occured:" @error
sleep 2
else
?"upload complete."
sleep 2
endif

Function WinHTTPPostRequest($sURL, $sFile, $uid, $pw)
; http://www.pstruh.cz/tips/detpg_post-binary-data-url.htm
Dim $http ;As New MSXML2.XMLHTTP

;Create XMLHTTP/ServerXMLHTTP/WinHttprequest object
;You can use any of these three objects.
;$http = CreateObject("WinHttp.WinHttprequest.5")
$http = CreateObject("MSXML2.XMLHTTP")
;$http = CreateObject("MSXML2.ServerXMLHTTP")
if @error $WinHTTPPostRequest=1 exit 1 endif

;Open URL As POST request
$http.Open("POST", $sURL, not 1, $uid, $pw)
if @error $WinHTTPPostRequest=2 exit 2 endif

;Set Content-Type header
$http.setRequestHeader("Content-Type", "multipart/form-data")
;$http.setRequestHeader("Content-Type", "multipart/form-data; boundary=
; >> Broken to two lines
;---------------------------15124220632234")
if @error $WinHTTPPostRequest=2 exit 2 endif

;Send the form data To URL As POST binary request
$http.send($sFile)
if @error $WinHTTPPostRequest=3 exit 3 endif

;Get a result of the script which has received upload
$WinHTTPPostRequest = $http.responseText
EndFunction

Method (2) LoadFromFile

Fails on LoadFromFile, position 5..

code:
if FTPPut("ftp://ftpserver/kdyer/kdyer", "c:\cr.dbf","uid","pw")
?"error occured:" @error
sleep 2
else
?"upload complete."
sleep 2
endif

Function FTPPut($sFile, $sURL, $uid, $pw)
Dim $oFTP, $oStream
$oFTP = CreateObject("Microsoft.XMLHTTP")
if @error $ftpput=1 exit 1 endif
$oStream = CreateObject("ADODB.Stream")
if @error $ftpput=2 exit 2 endif
$oStream.Type = 1
if @error $ftpput=3 exit 3 endif
$oStream.Open
if @error $ftpput=4 exit 4 endif
$oStream.LoadFromFile($sFile)
if @error $ftpput=5 exit 5 endif
$oFTP.Open("put", $sURL, not 1, $uid, $pw)
if @error $ftpput=6 exit 6 endif
;$oFTP.Send
;$oStream.setRequestHeader("Content-type", "image/jpeg")
;if @error $ftpput=5 exit 5 endif
$oFTP.Send($oStream.Read)
;$oStream.Mode = 3
;$oStream.open
;$oStream.Write($oFTP.responseBody)
;$oStream.SaveToFile($sFile, 2)
if @error $ftpput=5 exit 5 endif
$oStream.Close
EndFunction

Method (3) Function to generate Binary data
Did some prowling around on the web and found the following bit of code.

But fails on:

$lngNumber1 = $intDecimal / 2

Hmmm..
code:
break on
;ref - http://cwashington.netreach.net/depo/view.asp?Index=622&ScriptType=vbscript

$filename = "c:\cr.dbf"

$oFS = CreateObject("Scripting.FileSystemObject")
$File = $oFS.OpenTextFile($filename, 1, not 1, 0)

$Buffer = $File.Read(4)

$String = cbyte(asc($Buffer))

decimalToBinary($String)

Function decimalToBinary($intDecimal)
$strBinary = ""
$intDecimal = cInt($intDecimal)
While ($intDecimal > 1)
$lngNumber1 = $intDecimal / 2
$lngNumber2 = Fix($lngNumber1)
If ($lngNumber1 > $lngNumber2)
$strDigit = "1"
Else
$strDigit = "0"
EndIf
$strBinary = $strDigit + $strBinary
$intDecimal = Fix($intDecimal / 2)
Loop
$strBinary = "1" & $strBinary
While Len($strBinary) < 8
$strBinary = "0" + $strBinary
Loop
$binString = $strBinary
EndFunction

Thanks,

Kent


LonkeroAdministrator
(KiX Master Guru)
2002-12-06 05:25 PM
Re: FTP via InetCtls.Inet.1

kent, 1 can be skipped.
2 has the problem of ado not working and it still seems to be the best to use...


LonkeroAdministrator
(KiX Master Guru)
2002-12-06 05:28 PM
Re: FTP via InetCtls.Inet.1

should we skip the ado for moment and make the transfer happen with simple text-file?
this way it's problems do affect this.

anyway, is the multipart-form correct mime as it sais here is submit to you...
it should also have...
not sure but used on real form-data with vars and such...


LonkeroAdministrator
(KiX Master Guru)
2002-12-06 05:39 PM
Re: FTP via InetCtls.Inet.1

also, does it work with no priv if set to anonymous?
I think xmlhttp does this automatically but uses the same anonymous stuff than ie:
ieuser@

which is not supported by most of real ftp sites.


Kdyer
(KiX Supporter)
2002-12-10 08:57 AM
Re: FTP via InetCtls.Inet.1

Jooel,

Yes, we have now skipped ADO and have gone to a different methodology. Now, we need to get Public Function, Alias, and ByVal nailed down.

Here is what I have so far:
code:
 BREAK ON
CLS
; Ref - http://www.geocities.co.jp/SiliconValley/4805/vbtips/vbtips103.htm
FtpPut("ftp://ftpserver","kdyer","pw","ftp://ftpserver/kdyer/kdyer/test.jpg","c:\untitled1.jpg")
FUNCTION FtpPut($strftpsvr, $struserid, $strpassword, $strremotefile, $strlocalfile)
DIM $hinternet
DIM $hftp
DIM $lngret
DIM $strerrtext

$ftpput = True

IF @Error <> 0
GOTO ErrHandler
ENDIF

;INTERNET_OPEN_TYPE_PRECONFIG = 0&
$hinternet = InternetOpen("",0&,"","",0&)
IF $hinternet = 0
$strerrtext = "InternetOpen:GetLastError=" + $err.lastdllerror()
MESSAGEBOX ($strerrtext, $app.title + "<FtpPut>", 0)
$ftpput = NOT 1
RETURN
ENDIF

;INTERNET_DEFAULT_FTP_PORT = 21&
;INTERNET_SERVICE_FTP = 1&
$hftp = InternetConnect($hinternet, _
$strftpsvr, _
21&, _
$struserid, _
$strpassword, _
1&, _
0&, _
0&)
IF $hftp = 0
$strerrtext = "InternetConnect:GetLastError=" + $err.lastdllerror()
MESSAGEBOX($strerrtext, $app.title + "<FtpPut>", 0)
$ftpput = NOT 1
RETURN
ENDIF

;FTP_TRANSFER_TYPE_BINARY = &H2&
$lngret = FtpPutFile($hftp, _
$strlocalfile, _
$strremotefile, _
&H2&, _
0&)
$lngret = InternetCloseHandle($hftp)
$lngret = InternetCloseHandle($hinternet)
RETURN
:ErrHandler
$ftpput = NOT 1
MESSAGEBOX( "<" + $err + ">" + Error($err), $app.title + "<FtpPut>", 0 )
ENDFUNCTION

;-------------------------------------------------------
; Module
;-------------------------------------------------------
;constants
;INTERNET_OPEN_TYPE_PRECONFIG = 0&
;INTERNET_OPEN_TYPE_DIRECT = 1&
;INTERNET_OPEN_TYPE_PROXY = 3&
;INTERNET_DEFAULT_FTP_PORT = 21&
;INTERNET_DEFAULT_HTTP_PORT = 80&
;INTERNET_DEFAULT_HTTPS_PORT = 443&
;INTERNET_SERVICE_FTP As = 1&
;INTERNET_SERVICE_HTTP = 3&
;INTERNET_FLAG_PASSIVE = &H8000000
;INTERNET_FLAG_RELOAD = &H80000000
;FTP_TRANSFER_TYPE_ASCII = &H1&
;FTP_TRANSFER_TYPE_BINARY = &H2&

;API??

FUNCTION InternetOpen(Add($lpszAgent,"WinInet.DLL"),Add($dwAccessType,"WinInet.DLL"),
Add($lpszProxyName,"WinInet.DLL"),Add($lpszProxyBypass,"WinInet.DLL"0,Add($dwFlags,"WinInet.DLL")
; ;$inetopcstr = "wininet.dll"
; ;$inetopcstr = $inetopcstr + "InternetOpenA" + chr(40)
; $inetopcstr = $inetopcstr + Add($lpszAgent,"WinInet.DLL") + chr(44)
; $inetopcstr = $inetopcstr + Add($dwAccessType,"WinInet.DLL") + chr(44)
; $inetopcstr = $inetopcstr + Add($lpszProxyName,"WinInet.DLL") + chr(44)
; $inetopcstr = $inetopcstr + Add($lpszProxyBypass,"WinInet.DLL") + chr(44)
; $inetopcstr = $inetopcstr + Add($dwFlags,"WinInet.DLL")
ENDFUNCTION

FUNCTION InternetConnect($inetcstr)
$inetcstr = "WinInet.DLL"
$inetcstr = $inetcstr + "InternetConnectA" + chr(40)
$inetcstr = $inetcstr + Add($hInternetSession,"WinInet.DLL") + chr(44)
$inetcstr = $inetcstr + Add($lpszServerName,"WinInet.DLL") + chr(44)
$inetcstr = $inetcstr + Add($nServerPort,"WinInet.DLL") + chr(44)
$inetcstr = $inetcstr + Add($lpszUserName,"WinInet.DLL") + chr(44)
$inetcstr = $inetcstr + Add($lpszPassword,"WinInet.DLL") + chr(44)
$inetcstr = $inetcstr + Add($dwService,"WinInet.DLL") + chr(44)
$inetcstr = $inetcstr + Add($dwFlags,"WinInet.DLL") + chr(44)
$inetcstr = $inetcstr + Add($dwContext,"WinInet.DLL") + chr(41)
ENDFUNCTION

FUNCTION FtpPutFile($inetftpput)
$inetftpput = "wininet.dll"
$inetftpput = $inetftpput + "FtpPutFileA" + chr(40)
$inetftpput = $inetftpput + Add($hFtpSession,"WinInet.DLL") + chr(44)
$inetftpput = $inetftpput + Add($lpszLocalFile,"WinInet.DLL") + chr(44)
$inetftpput = $inetftpput + Add($lpszNewRemoteFile,"WinInet.DLL") + chr(44)
$inetftpput = $inetftpput + Add($dwFlags,"WinInet.DLL") + chr(44)
$inetftpput = $inetftpput + Add($dwContext,"WinInet.DLL") + chr(41)
ENDFUNCTION

FUNCTION InternetCloseHandle($inetclose)
$inetclose = "wininet.dll"
$inetclose = $inetclose + Add($hInternetSession,"WinInet.DLL") + chr(41)
ENDFUNCTION

; - Function Add is from Shawn Tassie since byval is not supported by KiX
; - ref - http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=13;t=000017
FUNCTION Add($var1,$var2byref)
;
; Add Var1 to Var2 (byref) and put result back into Var2 (byref)
;
$ = Execute("$Var2ByRef = $Var1 + $Var2ByRef") ; do it
ENDFUNCTION

Thanks,

Kent

[ 10. December 2002, 08:58: Message edited by: kdyer ]


LonkeroAdministrator
(KiX Master Guru)
2002-12-10 09:06 AM
Re: FTP via InetCtls.Inet.1

will see.
are you sure it has to be that long?
the ado method was a lot shorter [Wink]
or was it just because it didn't work [Razz]


Kdyer
(KiX Supporter)
2002-12-10 09:12 AM
Re: FTP via InetCtls.Inet.1

You can get LoadFromFile or...

Untested code... [Smile]

code:
break on

$file = "C:\AspEmail.dll"

ToBin($file)

Function StrConvert($vBin)
$oConv = CreateObject("ADODB.Stream")
$oConv.Charset = "utf-8"
$oConv.Type = 1 ;binary
$oConv.Open
$oConv.Write($vBin)
$oConv.Position = 0
$oConv.Type = 2 ;Text
$oConv.Charset = "Windows-1252" ;optionally
$StrConvert = $oConv.ReadText()
EndFunction

Or..
code:
Function ToBin($sString)
$oConv = CreateObject("ADODB.Stream")
$oConv.Charset = "Windows-1252"
$oConv.Type = 2 ; text
$oConv.Open
$oConv.WriteText($sString)
$oConv.Position = 0
$oConv.Type = 1 ;binary
;$oConv.Charset = "utf-8" ;optionally
$ToBin = $oConv.Read()
EndFunction

Working, please help yourself. [Big Grin]

Kent


LonkeroAdministrator
(KiX Master Guru)
2002-12-10 09:20 AM
Re: FTP via InetCtls.Inet.1

converting to string?
no binary transfer?


Kdyer
(KiX Supporter)
2002-12-10 09:26 AM
Re: FTP via InetCtls.Inet.1

As you may notice there are two different ones..

ToBin()
ToStr()

[Wink]

Kent


LonkeroAdministrator
(KiX Master Guru)
2002-12-10 09:28 AM
Re: FTP via InetCtls.Inet.1

well, didn't read tobin() before reply [Embarrassed]

Kdyer
(KiX Supporter)
2002-12-10 09:37 AM
Re: FTP via InetCtls.Inet.1

OK..

Here is some more information in my notes on this (probably nothing revolutionary, but maybe helpful):
quote:

Important The FTP protocol uses a single string that includes the =
operation name and any other parameters needed by the operation. In =
other words, the data and requestHeaders arguments are not used; all of =
the operations and their parameters are passed as a single string in the =
operation argument. Parameters are separated by a space. In the =
descriptions below, do not confuse the terms "file1" and "file2" with =
the data and requestHeaders arguments.

The syntax for FTP operations is:

operationName file1 file2.

For example, to get a file, the following code invokes the Execute =
method, which includes the operation name ("GET"), and the two file =
names required by the operation:

Inet1.Execute "FTP://ftp.microsoft.com", _
"GET Disclaimer.txt C:\Temp\Disclaimer.txt"
Note File names that include embedded spaces are not supported.

I did see -
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconusinginternettransfercontrol.asp

Notice that it uses Inet1

Hmmm..

Kent


LonkeroAdministrator
(KiX Master Guru)
2002-12-10 09:44 AM
Re: FTP via InetCtls.Inet.1

Add($lpszProxyName,"WinInet.DLL"),Add($lpszProxyBypass,"WinInet.DLL"0,Add($dwFlags,"WinInet.DLL")

should this be kixtart? if yes, there is syntax error...
going for cigarette


Kdyer
(KiX Supporter)
2002-12-10 06:29 PM
Re: FTP via InetCtls.Inet.1

I know.. I was trying to do a work-around.. I was reading what Shawn and New Mexico Mark were doing with byVal.

Hmm..

Kent


Kdyer
(KiX Supporter)
2002-12-10 06:33 PM
Re: FTP via InetCtls.Inet.1

For those who may have a challenge of reading the last bit of code in Japanese -

[URL=http://msdn.microsoft.com/code/default.asp?url=/msdn-files/026/001/985/Server%20Components/Visual%20Basic%20COM/FBLL%20(Fullfillment%20Business%20Logic%20Layer)/winine t_bas.asp]

May help.

{Edit}
Tried to get the URL to display right.. [Frown]

Kent

[ 10. December 2002, 18:39: Message edited by: kdyer ]


LonkeroAdministrator
(KiX Master Guru)
2002-12-10 07:49 PM
Re: FTP via InetCtls.Inet.1

yep.
this board is sh*t


LonkeroAdministrator
(KiX Master Guru)
2002-12-10 07:58 PM
Re: FTP via InetCtls.Inet.1

ok, what was the actual address as that one leads nowhere?

Kdyer
(KiX Supporter)
2002-12-10 08:12 PM
Re: FTP via InetCtls.Inet.1

Since it does not work with the URL listed..

Go to - http://msdn.microsoft.com/default.asp

Do a Search for wininet.bas in the Code and Downloads

Kent


LonkeroAdministrator
(KiX Master Guru)
2002-12-10 08:31 PM
Re: FTP via InetCtls.Inet.1

it gave me:
http://search.microsoft.com/gomsuri.asp?n=2&c=rp_Results&siteid=us/dev&target=http://msdn.microsoft.com/Downloads/samples/Internet/networking/vbhttp/sample.asp

and:
http://search.microsoft.com/gomsuri.asp?n=1&c=rp_Results&siteid=us/dev&target=http://msdn.microsoft.com/downloads/samples/internet/networking/vbftpjr/default.asp

which actually are:
http://msdn.microsoft.com/Downloads/samples/Internet/networking/vbhttp/sample.asp

and:
http://msdn.microsoft.com/downloads/samples/internet/networking/vbftpjr/default.asp


Kdyer
(KiX Supporter)
2002-12-10 10:27 PM
Re: FTP via InetCtls.Inet.1

Ouch..

[Embarrassed]

This should finally work.

MSDN Code Center

Kent


Kdyer
(KiX Supporter)
2002-12-11 07:49 PM
Re: FTP via InetCtls.Inet.1

Note:

Suggestions for -
  • LoadFromFile
  • Public Function
  • Alias
  • Byval
Have been posted in the Suggestions Forum:
LoadFromFile, Public Function, Alias, and Byval
Thanks!

Kent


LonkeroAdministrator
(KiX Master Guru)
2002-12-18 06:30 PM
Re: FTP via InetCtls.Inet.1

byval? [Wink]
part of these suggestions indeed has been asked multiple times and part of them indeed are actually needed for so many tasks.

so thanks.

I just hope we at some point get some information of ruuds todo-list.


Kdyer
(KiX Supporter)
2002-12-19 05:39 AM
Re: FTP via InetCtls.Inet.1

I guess the thing that we need to keep in mind is that KiX is not VB.. And VB is not KiX.

Kent


Kdyer
(KiX Supporter)
2002-12-19 05:42 AM
Re: FTP via InetCtls.Inet.1

I just wish we could use the LoadFromFile from

ADODB.Stream

Kent


LonkeroAdministrator
(KiX Master Guru)
2002-12-19 05:43 AM
Re: FTP via InetCtls.Inet.1

and that vb is not same as vbscript

vbscript is not capable of the sam stuff as kix.
and will not be as long as ruud will be shooting the walls down. and MS holding some stuff back from vbscripting.