Joe
Joe

Reputation: 1067

Creating an FTP Account with PHP (and/or Shell Scripts)

Im running a small project where I would like to have an FTP account made using a php execution. Either it be PHP itself or a shell script that gets called on, I googled and still found no cigar, so as a last hope I came here to ask if its possible, and if so If you can link me to a answer or provide your own on how to do it. Thanks.

Upvotes: 1

Views: 3297

Answers (1)

philwinkle
philwinkle

Reputation: 7056

<?php

shell_exec('useradd -G ftp ' . $username);

Where $username is the user and ftp is the group name. This assumes your ftp program has the group 'ftp' set up. Also, this may create a user's home directory in /home/$username so that will be the default FTP directory in most cases.

This also assumes that PHP is running as the root/privileged user to be able to run shell_exec(), which if you're on shared hosting is usually not available.

Note: This is also not available in safe mode.

Upvotes: 3

Related Questions