FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour FTPPutFile() requires too minutes to upload
Posts: 193
Joined: Wed Apr 04, 2007 06:54 AM
FTPPutFile() requires too minutes to upload
Posted: Sun Oct 26, 2025 03:50 PM

hi at all.

I have inserted a function into my programs that uploads a text file to an FTP server which I then access to consult some usage information.

lUpLoad := FTPPutFile( oFtp:hFTP, cFile, cWhere + cFile, FTP_TRANSFER_TYPE_BINARY, 0 )

The function runs when the program closes, but it takes too long (many minutes) to upload, so the program stays active in background.

Once the first upload is complete, subsequent uploads take a few seconds.

Is it possible to prevent the first upload from taking that long?

thanks

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: FTPPutFile() requires too minutes to upload
Posted: Mon Oct 27, 2025 02:47 PM

Can you provide a reduced and self-contained sample to reproduce the problem, please? We also need a test FTP account to make a test.

Posts: 193
Joined: Wed Apr 04, 2007 06:54 AM
Re: FTPPutFile() requires too minutes to upload
Posted: Mon Oct 27, 2025 08:14 PM

Thank you so much, Enrico, for your help.

I created a minimal function, but I can't provide you with a test FTP account. I'm staying with a friend who has an account at aruba.it.

Could my problem be due to security restrictions on the Aruba server? Or to the PC firewalls?

Every time I change the program's execution folder on my PC, uploading the file via FTP takes this interminable time.

The name of the file being uploaded is encrypted with the CharOdd() and CharEven() functions. Could this cause security issues when accessing it?

If you have any suggestions or modifications to the function, you're welcome. In the meantime, I'd better try to test it by removing the encryption and making some other changes.

UpLoadFile("File.txt", "ecc.it/users/")

FUNCTION UpLoadFile(cFile, cWhere)

LOCAL oInternet, oFtp, lUpLoad := .f.

oInternet := tInternet():New()



IF oInternet:hSession != 0

    oFtp  := tFtp():New("ftp.ecc.it", oInternet, cUser, cPass, 134217728)



    IF oFtp:hFTP != 0

        lUpLoad := FTPPutFile( oFtp:hFTP, cFile, cWhere + cFile, FTP_TRANSFER_TYPE_BINARY, 0 )  // PUNTO CRITICO CHE IMPIEGA MINUTI LA 1° VOLTA !

        oFtp:End()

    ENDIF

    oInternet:End()

ENDIF

Return(lUpLoad)

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: FTPPutFile() requires too minutes to upload
Posted: Mon Oct 27, 2025 08:37 PM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: FTPPutFile() requires too minutes to upload
Posted: Mon Oct 27, 2025 08:38 PM

I have an FTP account on Aruba too. I tried your sample with my account. The first time I run it, Windows Firewall asked me to allow the EXE, then it worked fine without any delay.

Posts: 193
Joined: Wed Apr 04, 2007 06:54 AM
Re: FTPPutFile() requires too minutes to upload
Posted: Tue Oct 28, 2025 07:02 AM

Enrico,

Try answering "no" to the firewall permission. You may need to rename the folder.

a good portion of users answer "no"

Thanks Karinha for the suggested posts. I'll study them...

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: FTPPutFile() requires too minutes to upload
Posted: Tue Oct 28, 2025 07:32 AM

If you answer no to the firewall then the program FTP communication will not work at all. That is normal and expected behavior.

Posts: 193
Joined: Wed Apr 04, 2007 06:54 AM
Re: FTPPutFile() requires too minutes to upload
Posted: Tue Oct 28, 2025 10:20 AM

Of course, if I answer "no" or "cancel," it won't load anything, but that's when it crashes. The function I posted should intercept the firewall's "no" and not launch the FTPPutFile() function, and it keeps doing that every time.

How can I verify that the firewall has not granted me permission?

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: FTPPutFile() requires too minutes to upload
Posted: Tue Oct 28, 2025 10:42 AM

The IFs you have already using are not enough?

Posts: 193
Joined: Wed Apr 04, 2007 06:54 AM
Re: FTPPutFile() requires too minutes to upload
Posted: Tue Oct 28, 2025 10:52 AM

Maybe none of those IFs control the firewall.

I need to make sure that if someone doesn't give permission, the function FTPPutFile() isn't launched.

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: FTPPutFile() requires too minutes to upload
Posted: Tue Oct 28, 2025 11:02 AM

Search the forum for alternative functions for FTP.

Posts: 193
Joined: Wed Apr 04, 2007 06:54 AM
Re: FTPPutFile() requires too minutes to upload
Posted: Tue Oct 28, 2025 11:28 AM

Thanks Enrico.

I'll do it.

I just verified that it's the function FTPPutFile() itself that triggers the firewall request, so it's not possible to exclude the function call with an IF statement.

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: FTPPutFile() requires too minutes to upload
Posted: Tue Oct 28, 2025 02:35 PM
I just tried this test below: it show a little dialog with .F. when the program is blocked by the firewall.
#include "Fivewin.ch"


FUNCTION MAIN()

    ? UPLOADFILE( "TEST.PRG", "emagsoftware.it/test/" )

    RETURN NIL


#define FTP_TRANSFER_TYPE_BINARY 2


STATIC FUNCTION UPLOADFILE( cFile, cWhere )

    LOCAL oInternet, oFtp, lUpLoad := .F.

    oInternet = TInternet():New()

    IF oInternet:hSession != 0
        oFtp = TFtp():New( "ftp.emagsoftware.it", oInternet, "userid", "password" )

        IF oFtp:hFTP != 0
            lUpLoad = FTPPUTFILE( oFtp:hFTP, cFile, cWhere + cFile, FTP_TRANSFER_TYPE_BINARY, 0 )
            oFtp:End()
        ENDIF

        oInternet:End()
    ENDIF

    RETURN lUpload
Posts: 193
Joined: Wed Apr 04, 2007 06:54 AM
Re: FTPPutFile() requires too minutes to upload
Posted: Tue Oct 28, 2025 03:27 PM

How long does it take for the function to return false? Because that's the critical point; it makes me wait for many minutes.

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: FTPPutFile() requires too minutes to upload
Posted: Tue Oct 28, 2025 03:35 PM

Almost instantly.