Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Jill Lindgren
  Where is Jill Lindgren?
 Charlton
 Massachusetts - United States
 Jill Lindgren
 To: Mike Gagnon
  Where is Mike Gagnon?
 Pointe Claire
 Canada
 Mike Gagnon
 Tags
Subject: RE: FTP Upload to Sub-Folder
Thread ID: 231987 Message ID: 231992 # Views: 26 # Ratings: 0
Version: Visual FoxPro 8 Category: Web, FTP and other Internet Protocols
Date: Thursday, June 18, 2009 7:14:04 PM         
   


> > Hi,
> >
> > A while back I got this great code from this forum and it works really well for uploading to an FTP site. The problem is, I can't figure out how to get it to upload to anything but the root folder.
> >
> > Anyone know how I can modify to upload to a folder several levels down from the root?
> >
> > Thanks.
> >
> > Jill Lindgren
> >
> > ****************************************************************************************
> > *: FTP UPLOAD CODE:
> >
> > PARAMETERS lcFileName
> >
> > Private pcNazwaZb,pcNazwaZbLoc,lpszServerName,lpszUsername,lpszPassword,;
> > pcPathNazwa,pcNazwaZbWysLoc,pcPathWysNazwa
> >
> >
> > #DEFINE INTERNET_OPEN_TYPE_DIRECT 1
> > #DEFINE INTERNET_INVALID_PORT_NUMBER 0
> > #DEFINE INTERNET_SERVICE_FTP 1
> > #DEFINE INTERNET_FLAG_PASSIVE 0x08000000
> > #DEFINE FILE_ATTRIBUTE_NORMAL 0x00000080
> > #DEFINE FTP_TRANSFER_TYPE_BINARY 0x00000002
> > #DEFINE FTP_ERROR "Error 1"
> > #DEFINE FTP_KOMENT "Error 2"
> > #DEFINE FTP_TRANSFER_TYPE_ASCII 0x00000001
> > #DEFINE INTERNET_FLAG_TRANSFER_ASCII FTP_TRANSFER_TYPE_ASCII
> > SET STEP ON
> >
> > DECLARE Integer InternetOpen IN WinINet ;
> > string lpszAgent, integer dwAccessType, string lpszProxyName, ;
> > string lpszProxyBypass, integer dwFlags
> >
> > DECLARE Integer InternetConnect IN WinINet ;
> > integer hInternet, string lpszServerName, ;
> > integer nServerPort, string lpszUsername, ;
> > string lpszPassword, integer dwService, ;
> > integer dwFlags, integer dwContext
> >
> > DECLARE INTEGER FtpPutFile IN wininet;
> > INTEGER hConnect,;
> > STRING lpszLocalFile,;
> > STRING lpszNewRemoteFile,;
> > INTEGER dwFlags,;
> > INTEGER dwContext
> >
> > DECLARE integer InternetCloseHandle IN WinINet ;
> > integer hInternet
> >
> > DECLARE INTEGER FtpGetCurrentDirectory IN wininet;
> > INTEGER hFtpSession,;
> > STRING @ lpszDirectory,;
> > INTEGER @ lpdwCurrentDirectory
> >
> > DECLARE INTEGER FtpSetCurrentDirectory IN wininet;
> > INTEGER hFtpSession,;
> > STRING @ lpszDirectory
> >
> > WAIT WINDOW "Sending file via FTP" nowait
> >
> > hInternet = InternetOpen('Ftp',INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0)
> >
> > IF hInternet = 0
> > = MESSAGEBOX(FTP_ERROR,64,FTP_KOMENT)
> > RETURN
> > EndIf
> >
> >
> > lpszServerName = ALLTRIM(tblsettings.ftpaddr)
> > lpszUsername = ALLTRIM(tblsettings.user)
> > lpszPassword = ALLTRIM(tblsettings.pass)
> > lpszDirectory = "web/GlobalWebCart/Stores/factoryservices/www/images/"
> >
> > pcNazwaZb = lcFilename
> > pcNazwaZbLoc= lcFilename
> > hConnect = InternetConnect(hInternet, lpszServerName, ;
> > INTERNET_INVALID_PORT_NUMBER, ;
> > lpszUsername, lpszPassword, ;
> > INTERNET_SERVICE_FTP, 0, 0)
> >
> > IF hConnect = 0
> > = InternetCloseHandle(hInternet)
> > = MESSAGEBOX(FTP_ERROR,64,FTP_KOMENT)
> > RETURN
> > ENDIF
> >
> > ** lpszDirectory = ''
> > ** lpdwCurrentDirectory = 0
> >
> > LOCAL cBuffer, nBufsize
> > nBufsize = 260
> > cBuffer = REPLICATE(CHR(0), nBufsize)
> > nRetCode = FtpGetCurrentDirectory(hConnect, @cBuffer, @nBufsize)
> >
> > nRetCode = FtpSetCurrentDirectory(hConnect,'dirname/upload')
> >
> > nBufsize = 260
> > cBuffer = REPLICATE(CHR(0), nBufsize)
> >
> > nRetCode = FtpGetCurrentDirectory(hConnect, @cBuffer, @nBufsize)
> >
> > nRetCode = FtpPutFile(hConnect,pcNazwaZbLoc,pcNazwaZb,INTERNET_FLAG_TRANSFER_ASCII,0)
> > = InternetCloseHandle(hInternet)
> >
> > MESSAGEBOX("FTP sent")
> > Return
>
> Should you use this as your target directory?
>
lpszDirectory = "web/GlobalWebCart/Stores/factoryservices/www/images/"
> nRetCode = FtpSetCurrentDirectory(hConnect,lpszDirectory)

>
>
> Mike Gagnon
> Refox XI +(English version)

ahhhh.. yes.. DUH. I can't believe I didn't see that.
Thanks for showing me the obvious.



COMPLETE THREAD
FTP Upload to Sub-Folder Posted by Jill Lindgren @ 6/18/2009 6:26:41 PM
RE: FTP Upload to Sub-Folder Posted by Mike Gagnon @ 6/18/2009 6:43:13 PM
RE: FTP Upload to Sub-Folder Posted by Jill Lindgren @ 6/18/2009 7:14:04 PM
RE: FTP Upload to Sub-Folder Posted by Borislav Borissov @ 6/18/2009 7:31:59 PM
RE: FTP Upload to Sub-Folder Posted by Jill Lindgren @ 6/18/2009 7:40:02 PM