Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

File Transfer without using FTP Protocol in Foxpro

1,262 views
Skip to first unread message

Humty

unread,
Aug 1, 2003, 3:37:13 PM8/1/03
to
Hello:

We are distributing a foxpro application that uses
Microsoft FTP to send files back to the server. Malicious
users dumped files on our Win 2K server when the ftp
service was perpetually enabled. So, I have a a few
questions:

1. Is it possible to send files to our server from within
a (remotely running) foxpro application without using ftp,
say using http instead of ftp.

2. Is there a way that the ftp service can be started and
stopped on the Win2k Server from within a foxpro
application running remotely?

3. Are there any other ways of sending small files to our
server from a remotely running foxpro application?

Thank you.

Humty


Eric den Doop

unread,
Aug 1, 2003, 3:57:59 PM8/1/03
to
Hello, Humty!
You wrote on Fri, 1 Aug 2003 12:37:13 -0700:

H> We are distributing a foxpro application that uses
H> Microsoft FTP to send files back to the server. Malicious
H> users dumped files on our Win 2K server when the ftp
H> service was perpetually enabled. So, I have a a few
H> questions:

H> 1. Is it possible to send files to our server from within
H> a (remotely running) foxpro application without using ftp,
H> say using http instead of ftp.

HTTP should work. Not sure if it supports http file transfer, but you might
want to check wwipstuff from www.west-wind.com. You can also use webserver
based scripts. I know there are free Perl scripts available on the net.
However, if you want to play it save, use a VPN connection. You can have
your VFP app to dial in to a remote VPN server, drop the files using FTP or
simply by using the COPY FILE command. Use the STRUCT class from
www.universalthread.com to dial in to RAS/VPN servers.
Didn't you set up a password & user name on the FTP server?

H> 2. Is there a way that the ftp service can be started and
H> stopped on the Win2k Server from within a foxpro
H> application running remotely?

I think this can be done if you're logged on to the LAN of the FTP server
(can be done using VPN). You might have to install the Windows 2000 Resource
Kit on the remote computer.

H> 3. Are there any other ways of sending small files to our
H> server from a remotely running foxpro application?

E-mail?
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8


Dan Freeman

unread,
Aug 1, 2003, 4:30:54 PM8/1/03
to
Your problem here isn't FTP, as such, it's *anonymous* FTP.

Instead of allowing anyone and everyone to FTP files to you,
password-protect that directory with a password known only to your
application.

You could use http, but you'll end up with the same problem as long as
you're allowing anonymous connections.

Dan

"Humty" <humt...@yahoo.com> wrote in message
news:019701c35864$4ed0b360$a501...@phx.gbl...

Glen Wagner

unread,
Aug 1, 2003, 7:20:21 PM8/1/03
to
Can someone give me some sample code has to how to initate
a file transfer from within Foxpro.
I have an import and export routine that sure could use
such a thing
Thanks
Glen
>.
>

Edhy Rijo

unread,
Aug 1, 2003, 8:02:03 PM8/1/03
to
Hi Glen,

I use a library called Focus.fll from www.fastwrite.com it has ton of
functions specially for VFP applications, including FTP, ZIP(without
password yet!), etc. All the functions are very well documented and really
easy to use. For a project I was experimenting with the Mabry controls and
I had to code so many lines to make it work, with the functions in Focus.fll
it was like 123 <s>.

P.S.
All the functions are very well documented.

--
Edhy Rijo
Programming System Solutions www.progytech.com
Bronx NY

"Glen Wagner" <mozil...@hotmail.com> wrote in message
news:02c601c35883$7aaaa670$a501...@phx.gbl...

Heberto Villavicencio

unread,
Aug 1, 2003, 8:53:25 PM8/1/03
to
**
** Upload files to ftp server
**

#DEFINE GENERIC_READ 2147483648 && &H80000000
#DEFINE GENERIC_WRITE 1073741824 && &H40000000

PUBLIC hOpen, hFtpSession
DECLARE INTEGER InternetOpen IN wininet.dll;
STRING sAgent,;
INTEGER lAccessType,;
STRING sProxyName,;
STRING sProxyBypass,;
STRING lFlags

DECLARE INTEGER InternetCloseHandle IN wininet.dll;
INTEGER hInet

DECLARE INTEGER InternetConnect IN wininet.dll;
INTEGER hInternetSession,;
STRING sServerName,;
INTEGER nServerPort,;
STRING sUsername,;
STRING sPassword,;
INTEGER lService,;
INTEGER lFlags,;
INTEGER lContext

DECLARE INTEGER FtpOpenFile IN wininet.dll;
INTEGER hFtpSession,;
STRING sFileName,;
INTEGER lAccess,;
INTEGER lFlags,;
INTEGER lContext

DECLARE INTEGER InternetWriteFile IN wininet.dll;
INTEGER hFile,;
STRING @ sBuffer,;
INTEGER lNumBytesToWrite,;
INTEGER @ dwNumberOfBytesWritten

IF connect2ftp ("ftp.yourftpserver.com", "user", "password")
lcSourcePath = "C:\upload\" && local folder
lcTargetPath = "/www/" && remote folder (ftp server)

lnFiles = ADIR (arr, lcSourcePath + "*.*")

FOR lnCnt=1 TO lnFiles
lcSource = lcSourcePath + LOWER (arr [lnCnt, 1])
lcTarget = lcTargetPath + LOWER (arr [lnCnt, 1])
? lcSource + " -> " + lcTarget
?? local2ftp (hFtpSession, lcSource, lcTarget)
ENDFOR

= InternetCloseHandle (hFtpSession)
= InternetCloseHandle (hOpen)
ENDIF

FUNCTION connect2ftp (strHost, strUser, strPwd)
** Abrimos el acceso.
hOpen = InternetOpen ("vfp", 1, 0, 0, 0)

IF hOpen = 0
? "No tiene acceso a WinInet.Dll"
RETURN .F.
ENDIF

** Connect to FTP.
hFtpSession = InternetConnect (hOpen, strHost, 0, strUser, strPwd, 1, 0,
0)

IF hFtpSession = 0
** Close
= InternetCloseHandle (hOpen)
? "FTP " + strHost + " not ready"
RETURN .F.
ELSE
? "Conectado a " + strHost + " como: [" + strUser + ", *****]"
ENDIF
RETURN .T.


**--------------------------------------------
** Copia del/los archivos
**--------------------------------------------
FUNCTION local2ftp (hConnect, lcSource, lcTarget)
** Upload local file to ftp server
hSource = FOPEN (lcSource)
IF (hSource = -1)
RETURN -1
ENDIF

** New file in ftp server
hTarget = FtpOpenFile(hConnect, lcTarget, GENERIC_WRITE, 2, 0)
IF hTarget = 0
= FCLOSE (hSource)
RETURN -2
ENDIF
lnBytesWritten = 0
lnChunkSize = 512 && 128, 512
DO WHILE Not FEOF(hSource)
lcBuffer = FREAD (hSource, lnChunkSize)
lnLength = Len(lcBuffer)
IF lnLength > 0
IF InternetWriteFile (hTarget, @lcBuffer, lnLength, @lnLength) =
1
lnBytesWritten = lnBytesWritten + lnLength
? lnBytesWritten
** Show Progress
ELSE
EXIT
ENDIF
ELSE
EXIT
ENDIF
ENDDO

= InternetCloseHandle (hTarget)
= FCLOSE (hSource)

RETURN lnBytesWritten

"Glen Wagner" <mozil...@hotmail.com> escribió en el mensaje
news:02c601c35883$7aaaa670$a501...@phx.gbl...

Glen Wagner

unread,
Aug 1, 2003, 9:43:18 PM8/1/03
to
Heberto
WOW thanks so much
Glen
>.
>

Eric den Doop

unread,
Aug 2, 2003, 6:27:43 AM8/2/03
to
Hello, Glen!
You wrote on Fri, 1 Aug 2003 16:20:21 -0700:

GW> Can someone give me some sample code has to how to initate
GW> a file transfer from within Foxpro.
GW> I have an import and export routine that sure could use
GW> such a thing

Download the free FTPCLASS from the universalthread for a complete FTP
solution written in VFP.

Humty

unread,
Aug 4, 2003, 11:11:39 AM8/4/03
to
Thank you all for your help!

-Humty

>.
>

Glen Wagner

unread,
Aug 4, 2003, 8:05:38 PM8/4/03
to
Heberto
I got the posting down.
But
I am having troubles retrieving.
in particular ftpfindfirstfile and internetfindnext file
could i bother you for an example of those also :)
BTW
with what I have learned from you last week I have created
a web cam so I can watch my cat lye around the house all
day while I am working :)
thanks
Glen
>.
>

Heberto Villavicencio

unread,
Aug 4, 2003, 9:11:23 PM8/4/03
to
Sorry, no examples for ftpfindfirstfile and internetfindnext but find in
MSDN online

"Glen Wagner" <mozil...@hotmail.com> escribió en el mensaje

news:86bd01c35ae5$4d36e640$a001...@phx.gbl...

Edhy Rijo

unread,
Aug 5, 2003, 2:36:58 AM8/5/03
to
Hi Glen,

I see you still have some problems with this <s>. Just download the demo
for focus.fll and try, it may surprise you! That's what I did, after getting
frustrated with Mabry, the Focus.fll came to the rescue, www.fastwrite.com

--
Edhy Rijo
Programming System Solutions www.progytech.com
Bronx NY

"Glen Wagner" <mozil...@hotmail.com> wrote in message

news:86bd01c35ae5$4d36e640$a001...@phx.gbl...

Glen Wagner

unread,
Aug 5, 2003, 2:08:39 PM8/5/03
to
Ok Edhy im going to try it
I just dont like downloading stuff into my apps would
rather create or have huberto create for me :P
Im going there now to look and see
I have the up to the net down and working ,, but the down
from the net requires me to do some stuff like
findfirstfile then i guess i store it off and loop thru a
findnextfile till i get a 0 returned.
cant seem to get that code down. the files could have one
of 4 extentions and the first 2 letters of the name are
the same depending on the file but the next 8 change from
store to store. this is working good in floppy transfer
but i was tryn to make it easier for the end user.
anyway off to grab focus.dll
thanks
Glen
>.
>
Message has been deleted
0 new messages