How to download files from database using Free Pascal/Lazarus

After uploading files in the previous example into database, now we need to download that files: Create new Lazarus project to open and browse Photos table in this form: Download button will prompt you to specify where to download the file. Write this code in Download button’s OnClick:

How to upload files into database using Free Pascal/Lazarus

To upload files into database, such as photos or any other files type, you need first to create a Blob field in a proper table structure in your favourite database engine. For this example we are using FireBird database table: Create a new Lazarus application and add the following components: TButton, TIBConnection, TSQLTransaction, TSQLQuery, and TOpenDialog:…

How to copy files in Free Pascal

To copy files in Free Pascal, you can do it in many ways, one of them is to use TStreamFile‘s CopyFrom method. This example could copy any type of files without changing it’s contents. But destination file information will be changed, like file name, and updated time.