Error FTP

Error FTP

Postby mariordz » Thu Mar 16, 2023 8: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: Select all  Expand view  RUN
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: Select all  Expand view  RUN
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: Select all  Expand view  RUN
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.
User avatar
mariordz
 
Posts: 131
Joined: Tue Dec 26, 2006 4:50 pm
Location: Ciudad de México

Re: Error FTP

Postby Enrico Maria Giordano » Fri Mar 17, 2023 9:29 am

Please send to my private email a little PRG that I can compile and execute here to reproduce the error.
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Error FTP

Postby wartiaga » Fri Mar 31, 2023 7: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!
wartiaga
 
Posts: 212
Joined: Wed May 25, 2016 1:04 am

Re: Error FTP

Postby mariordz » 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.
User avatar
mariordz
 
Posts: 131
Joined: Tue Dec 26, 2006 4:50 pm
Location: Ciudad de México

Re: Error FTP

Postby Enrico Maria Giordano » Sat Apr 01, 2023 7:43 am

wartiaga wrote:
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.
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Error FTP

Postby wartiaga » 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!
wartiaga
 
Posts: 212
Joined: Wed May 25, 2016 1:04 am

Re: Error FTP

Postby wartiaga » Mon Apr 03, 2023 10:47 pm

Enrico Maria Giordano wrote:
wartiaga wrote:
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.
wartiaga
 
Posts: 212
Joined: Wed May 25, 2016 1:04 am

Re: Error FTP

Postby Enrico Maria Giordano » Tue Apr 04, 2023 8: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: Select all  Expand view  RUN
#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 )
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 17 guests