What can we improve?

Documentation

(Edit)

Translation is in progress...
Not all topics are available at the moment and content links may be broken.

Using FTP

It is possible to access files that are stored on an FTP server via script.

Prepare FTP server

If this was not done already, it is required to set up and configure an FTP server. The explanation will be given for the tool FileZilla Server. However, the process is similar for other tools.

During the installation, FileZilla Server already initializes an FTP server on the local host, if needed.

Connect to Server

When launching the tool, the shown dialog is opened. It is used to connect to the created FTP server. If the default settings from the installation were used, the data can be used as shown in the screenshot, i.e., "Host": "localhost", "Port": 14147, and no password.

In most cases, the firewall needs to be configured to allow access to the FTP server. The process is explained for Filezilla here

Creating a Group

The next step is setting up a group for users. Groups can be used to categorize users and provide different rights or accessible folders. However, it is also possible to simply create a single group that is used for all users, thus providing the same rights to every user.

Edit -> Groups

Add Group

Select Group Name

The Groups settings can be accessed via the menu "Edit->Groups". In the shown dialog, a new group can be added via "Add" below the initially empty list of groups. After entering a name and confirming the choice, a new group is created.

Add Shared Folder

Select Folder

In the category "Shared folders", the folder that is meant to be accessed via FTP is chosen by clicking "Add" below the initially empty list of directories. This will open a dialog to select a folder.

Configure Rights

After adding a shared folder, it is possible to configure the rights of accessing the folder. By default, the files in the folder and its subdirectories can be read but not modified.

Creating a User

Edit -> Users

Add User

Choose User Name and Group

New users are added in the Users settings that are accessed via "Edit->Users". A new user is added by clicking "Add" below the initially empty list of users. In the shown dialog, a user name and a group is chosen. After confirming the choice, the user is added.

Set Password

A password can be set for the newly created user by activating the checkbox "Password" and entering a chosen password.

If only one user exists, the creation of a group can be skipped. Instead, the user is assigned a shared folder directly.

Access a File from the FTP Server via Script

$address = "ftp://my-user:password@localhost/test.txt";
$contents = file_get_contents($address);
 
echo $contents;

A file on an FTP server can be accessed like it was a local file. Merely the address of the file changes. The code example reads and outputs the content of the file "test.txt" on the local FTP server. The address is structered as follows: "ftp://<user>(:<password>)@<servername>/<path-to-file>".

It is also possible to use special FTP functions when accessing an FTP server as shown here

Deutsche Webseite verfügbar
Go to cart
Any questions?