Recent

Author Topic: Putting a new file on a web-site  (Read 922 times)

Thaddy

  • Hero Member
  • *****
  • Posts: 19607
  • Glad to be alive.
Re: Putting a new file on a web-site
« Reply #15 on: July 18, 2026, 06:41:19 am »
I do know that in FileZilla I have 'Protocol' set to SFTP - SSH rather than just FTP and that has been working for a very long time.
That indicates to me there is a wrong protocol used (again, get tired of that). Update OpenSSL and set the protocol to tls1.1 at a minimum.
OpenSSL removed protocols with security issues, so they won't work.
Well maintained webservers do not accept those protocols, so they won't work either.
If it worked in the past, update your libraries and update your code.
sftp is a good choice btw, not ftps.

But even older FileZilla's won't work because of the same issue: dropped protocols.
A newer FileZilla might work, but I don't know how well it is maintained.
Just like you they need to update the protocols every now and then.
« Last Edit: July 18, 2026, 06:53:42 am by Thaddy »
Any "programmer" that knows only one programming language is not a programmer

paweld

  • Hero Member
  • *****
  • Posts: 1696
Re: Putting a new file on a web-site
« Reply #16 on: July 18, 2026, 08:07:59 am »
@J-G Take a look at the attached project. It’s not a direct answer to your question, but it should solve your problem. It’s a simple PHP API (the “versions.php” file) that you need to place on your website (your web server must support PHP), along with a sample application that shows how to add information about new versions and how to retrieve it.
The API allows you to add information about new versions (program name, version number, date, list of changes) in one place (you don’t have to upload files to the server for each program separately). Additionally, you can display the release date and changes to the user. It has simple authentication using an “X-API-Key,” so only an authorized person will be able to add changes.
Best regards / Pozdrawiam
paweld

paweld

  • Hero Member
  • *****
  • Posts: 1696
Re: Putting a new file on a web-site
« Reply #17 on: July 18, 2026, 08:30:32 am »
And if you still want to upload a file, but your server doesn't support FTP - only SFTP, then use the solution shared by @rvk : https://forum.lazarus.freepascal.org/index.php/topic,28053.msg174915.html#msg174915
Best regards / Pozdrawiam
paweld

Roland57

  • Hero Member
  • *****
  • Posts: 624
    • msegui.net
Re: Putting a new file on a web-site
« Reply #18 on: July 18, 2026, 12:04:05 pm »
@J-G

Yesterday after reading this discussion, I did some experiments, and discovered that FtpPutFile didn't work for me.

I finally found something that works (using TFTPSend). I attached it here, in case it is useful. Tested only under Linux.
My projects are on Codeberg.

J-G

  • Hero Member
  • *****
  • Posts: 1209
Re: Putting a new file on a web-site
« Reply #19 on: July 18, 2026, 04:43:36 pm »
A little while ago I think that I read in one of the posts by @cdbc  that said "The morning brings clariity"  -  or at least words with that sentiment!

I cannot fathom where my head was going yesterday  -  I suspect that I was probably annoyed that the 'Writing to the web' didn't just 'work'  :o

There is no way that I need to recreate a FileZilla clone !!   -   Being able to READ a file from the web-site and compare the data to that held locally is perfectly reasonable. From that, a decision can be made as to what to do. In this case it is simply to alert the user that I've created a newer version of the program and made it available. The Program (as a .ZIP file) can be uploaded via FileZilla perfectly easily along with the small text file that has the Version N°.  I've even fathomed how to inhibit the display of the 'Version.txt' file  :-X

I've spent the morning reviewing my options - including looking at INDY, and the offerings/suggestions from @paweld, @Rowland57 et. al.  as well as creating appropriate User Alerts / Notices so that they can make informed choices as to which way they want to proceed.

The result is not as 'sleek' as the update path offered by the likes of FileZilla or SyncBack (for instance) and it does rely upon the user to be basically competent (ie. knowing how to UnZip and save via a browser  -  though I have taken steps to create backup files as a 'fall-back'.

Essentially, If the web 'Version' file is greater than the local 'Version' then a Panel is displayed with [Accept] and [Decline] buttons. The [Decline] button simply tells the user that they'll be reminded again at the next 'Run' and hides the Panel.  The [Accept] button backs up the existing .ZIP file and opens a browser pointing to the Web folder with just the  new .ZIP file available so that they can save it at their own discresion. After which the program's 'FormClose' proc is called to update the Version N° and save all the current settings/historic data before eventually calling Application.Terminate.

Thanks to all contributors, I've learned quite a bit about the potential problems of dealing with web-based data - though there is a great deal more to be discovered !!
 
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

J-G

  • Hero Member
  • *****
  • Posts: 1209
Re: Putting a new file on a web-site
« Reply #20 on: July 18, 2026, 08:19:07 pm »
@J-G

Yesterday after reading this discussion, I did some experiments, and discovered that FtpPutFile didn't work for me.

I finally found something that works (using TFTPSend). I attached it here, in case it is useful. Tested only under Linux.

@Roland -  I'm just looking at your suggestion - specifically tftpsend2 and although I can sort out how to add laz_synapse to the Project Inspector, I don't know what package I should be adding for ssl_openssl3. - there are no results starting 'ssl'

Could you enlighten me ?  It may be useful to test under Windows.
« Last Edit: July 18, 2026, 08:20:51 pm by J-G »
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

Roland57

  • Hero Member
  • *****
  • Posts: 624
    • msegui.net
Re: Putting a new file on a web-site
« Reply #21 on: July 18, 2026, 09:07:00 pm »
@J-G

I used Synapse from the GitHub repository. The ssl_openssl3 unit is included in it.
My projects are on Codeberg.

J-G

  • Hero Member
  • *****
  • Posts: 1209
Re: Putting a new file on a web-site
« Reply #22 on: July 18, 2026, 11:10:43 pm »
Given this further nugget of infomation, I looked at the link provided and can see ssl_openssl3.pas - so, I downloaded it into a fresh folder.  But then I did a search of my disk and low & behold there is the same file in the synapse folder - in fact there are two files - .pas  & _lib.pas.  There are no .o or .ppu  files  (which I assume are created along with the 'unit')

Now this confuses my puny brain, since I have installed synapse and added it to the Project Inspector - so why has the unit ssl_openssl3 not been created ?? 

More to the point, what do I need to do to create a 'unit' from the .pas file - which I assume is what should have happened.


FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

J-G

  • Hero Member
  • *****
  • Posts: 1209
Re: Putting a new file on a web-site
« Reply #23 on: July 25, 2026, 02:46:14 pm »
Now that I have resolved the issue I had with trapping the 404 error when READING from the web, I'm now looking again at the problem I had in WRITING to the web.

You may recall that I was unable to proceed because the ssl_openssl3 Unit had not appeared when I installed Synapse  and I didn't know how to create it - even though I had the ssl_openssl3.pas source code. In my efforts to understand reading from the web more fully I did a great deal of re-organisation of my current project which entailed the creation of 3 new 'general purpose' units - one for Print & Text handling, one for File handling & one for Maths, This gave me some better insight even though I'd created a Date & Time Unit some years ago.

This led me to experiment so I added a [New Unit] to my project and copied in the code from ssl_openssl3.pas. As anticipated upon Compiling [f9] I was asked to 'save' the unit which I did in the Synapse40.1 folder. The program compiled correctly but I had a notice that the unit path was not included and should Laz add it. Of course I responded positively but now have a warning at the top of the 'Messages' :
Warning: other unit files search path (aka unit path) of "Triangle" contains "Q:\Stable\laz_conf\onlinepackagemanager\packages\synapse40.1", which belongs to package "laz_synapse".

I presume that this will be ever-present unless I relocate the 'Unit'.

The question is, can I simply copy ssl_openssl3.lps (I do not see an ssl_openssl3.o or ssl_openssl3.ppu) to the folder that contains laz_synapse, or should I simply ignore the warning.

The project compiles and has the ssl_openssl3 in the Units Clause so that is at least a step foreward, but I now need to resurrect the dormant code which writes to the web to see whether it now operates (or not [more likely, I fear]).
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

Nimbus

  • Full Member
  • ***
  • Posts: 105
Re: Putting a new file on a web-site
« Reply #24 on: July 25, 2026, 03:08:17 pm »
I do know that in FileZilla I have 'Protocol' set to SFTP - SSH rather than just FTP and that has been working for a very long time.

This tells us that the protocol in use is SFTP - i.e. file transfers over SSH. Therefore, FTP(S) solutions aren't going to work - SFTP has nothing to do with FTP or FTPS.
Unfortunately, FPC doesn't include a standard unit to work with SFTP, neither do Synapse nor Indy (as far as I know).

There was an old unit in the Synapse contrib directory though
http://synapse.ararat.cz/files/contrib/sftp.zip
(the site is on insecure http, modern browsers will surely prevent direct link downloads; if so, try navigating to http://synapse.ararat.cz/files/contrib/ and click sftp.zip there)
However this is quite old, relies on some Synapse units, and more importantly - on cr32.dll to be available. You may give it a shot, but I am not quite sure it's still compatible with modern 64-bit Windows, or if it's worth the effort (never used it myself).

J-G

  • Hero Member
  • *****
  • Posts: 1209
Re: Putting a new file on a web-site
« Reply #25 on: July 25, 2026, 05:45:48 pm »
Thanks for your input @Nimbus.

I have now resurected the dormant code and can compile my project with ssl_openssl3 in the Uses clause and can confirm that it is still not successful.

This seems to confirm that I do need SFTP rather than FTP and even with my backward looking attitude I don't feel too inclined to seek out what seems to be potentially old code that may or may not be worthwhile. 

I had considered that it might be useful to have the user seemlessly write back to my site when they had downloaded a new version but I think my time would be better spent in developing more helpful utilities.  -  now the Triangle program is 'useful' I'm thinking about a 'Polygon' mate  :D
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

 

TinyPortal © 2005-2018