FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Error FTP
Posts: 131
Joined: Tue Dec 26, 2006 04:50 PM
Error FTP
Posted: Thu Mar 16, 2023 08:44 PM
To all, but specially to Mr. Enrico Maria Giordano, I have been using you method to upload and download files from an FTP site for years, today it started sending an strange message when trying to upload/download files, I made no changes to the code, perhaps you will be so kind as to help me figure out the problem, I have this code:
Code (fw): Select all Collapse
FUNCTION UPLOADFTP( cFileftp )
    #define FILE_ATTRIBUTE_READONLY  1
   #define FILE_ATTRIBUTE_HIDDEN    2
   #define FILE_ATTRIBUTE_SYSTEM    4
   #define FILE_ATTRIBUTE_DIRECTORY 16
   #define FILE_ATTRIBUTE_ARCHIVE   32
   #define FILE_ATTRIBUTE_NORMAL    128
   #define FILE_ATTRIBUTE_TEMPORARY 256
   #define INTERNET_OPEN_TYPE_PRECONFIG                    0   // use registry configuration
   #define INTERNET_OPEN_TYPE_DIRECT                       1   // direct to net
   #define INTERNET_OPEN_TYPE_PROXY                        3   // via named proxy
   #define INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY  4   // prevent using java/script/INS
   #define INTERNET_INVALID_PORT_NUMBER    0           // use the protocol-specific default
   #define INTERNET_DEFAULT_FTP_PORT       21          // default for FTP servers
   #define INTERNET_DEFAULT_GOPHER_PORT    70          //    "     " gopher "
   #define INTERNET_DEFAULT_HTTP_PORT      80          //    "     " HTTP   "
   #define INTERNET_DEFAULT_HTTPS_PORT     443         //    "     " HTTPS  "
   #define INTERNET_DEFAULT_SOCKS_PORT     1080        // default for SOCKS firewall servers.
   #define INTERNET_SERVICE_FTP     1
   #define INTERNET_SERVICE_GOPHER  2
   #define INTERNET_SERVICE_HTTP    3
   #define INTERNET_FLAG_TRANSFER_ASCII  1
   #define INTERNET_FLAG_TRANSFER_BINARY 2
   #define GENERIC_READ  2147483648
   #define GENERIC_WRITE 1073741824
   LOCAL hInternet, hConnect, hSource, hDest, nRead
   LOCAL cData := SPACE( 1024 )
   LOCAL nPos := 0
   cFile:=cFileftp
    cFildes:="/files/"+cFilename(cFile)
   hInternet = INTERNETOPEN( "Anystring", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0 )
   hConnect = INTERNETCONNECT( hInternet, "myipaddress", INTERNET_INVALID_PORT_NUMBER, "myuser", "mypassword", INTERNET_SERVICE_FTP, 0, 0 )
   hDest = FTPOPENFILE( hConnect, cFildes, GENERIC_WRITE, 0, 0 )
   hSource = FOPEN( cFile )
   WHILE .T.
    nRead = FREAD( hSource, @cData, LEN( cData ) )
      IF nRead = 0
        IF FERROR() = 0
            *? "El archivo ha sido generado exitosamente"
        ELSE
            ? "Error al generar el archivo en el site FTP"
            ENDIF
         EXIT
        ENDIF
      IF !INTERNETWRITEFILE( hDest, @cData, nRead )
        ? "Error al intentar escribir el archivo en el servidor"
         EXIT
        ENDIF
      nPos += LEN( cData )
    ENDDO
    FCLOSE( hSource )
    INTERNETCLOSEHANDLE( hDest )
    INTERNETCLOSEHANDLE( hConnect )
    INTERNETCLOSEHANDLE( hInternet )
    oDlg:end()
    delete file &cFileftp
RETURN NIL
I got this error:
Code (fw): Select all Collapse
Error description: Error BASE/1099  Error de argumento: STR
   Args:
     [   1] = U   

Stack Calls
===========
   Called from:  => STR( 0 )
   Called from: .\source\winapi\WININET.PRG => INTERNETOPEN( 44 )
   Called from: C:\xDevStudio\Projects\Tubelite\Source\Tubelite.prg => UPLOADFTP( 8964 )
   Called from: C:\xDevStudio\Projects\Tubelite\Source\Calendar.prg => ACTUAL( 1149 )
The wininet.prg file line 41 to 44 reads this:
Code (fw): Select all Collapse
DLL32 FUNCTION InternetOpen( cApp as LPSTR, n1 AS DWORD, n2 AS LPSTR, n3 AS LPSTR,;
                             n4 AS DWORD ) AS LONG PASCAL ;
                             FROM "InternetOpenA" LIB hWinINet
Any idea what is happenig?

Thanks for your help.
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Error FTP
Posted: Fri Mar 17, 2023 09:29 AM

Please send to my private email a little PRG that I can compile and execute here to reproduce the error.

Posts: 253
Joined: Wed May 25, 2016 01:04 AM
Re: Error FTP
Posted: Fri Mar 31, 2023 07:56 PM
Enrico Maria Giordano wrote:Please send to my private email a little PRG that I can compile and execute here to reproduce the error.
Enrico, any news? I have the same error.

Thanks!
Posts: 131
Joined: Tue Dec 26, 2006 04:50 PM
Re: Error FTP
Posted: Fri Mar 31, 2023 11:22 PM

Enrico send me another piece of code that worked for me, if you want to give it a try let me know your email address to send the example I got, I am sure it will work for you as well.

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Error FTP
Posted: Sat Apr 01, 2023 07:43 AM
wartiaga wrote:
Please send to my private email a little PRG that I can compile and execute here to reproduce the error.
Enrico, any news? I have the same error.

Thanks!
Please, can you send me the sample again? I also need server, userid and password to do a test here.
Posts: 253
Joined: Wed May 25, 2016 01:04 AM
Re: Error FTP
Posted: Sat Apr 01, 2023 12:11 PM
mariordz wrote:Enrico send me another piece of code that worked for me, if you want to give it a try let me know your email address to send the example I got, I am sure it will work for you as well.
Please send to w_peixoto@hotmail.com.
Thank you!
Posts: 253
Joined: Wed May 25, 2016 01:04 AM
Re: Error FTP
Posted: Mon Apr 03, 2023 10:47 PM
Enrico Maria Giordano wrote:
Please send to my private email a little PRG that I can compile and execute here to reproduce the error.
Enrico, any news? I have the same error.

Thanks!
Please, can you send me the sample again? I also need server, userid and password to do a test here. Enrico I sent in your email a prg with the data to connect in the ftp. Returns .F. when you run the FTPPutFile command. Thank you for your help.
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Error FTP
Posted: Tue Apr 04, 2023 08:17 AM
Fixed and sent to your private email. Your ftp server doesn't allow active ftp mode. The sample now uses passive ftp mode:
Code (fw): Select all Collapse
#define INTERNET_FLAG_PASSIVE 134217728

hConnect = INTERNETCONNECT( hInternet, "ftp.fenatac.log.br", INTERNET_INVALID_PORT_NUMBER, "fenatac@fenatac.log.br", "%?*%S+,@N_,%", INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0 )

Continue the discussion