Here's my problem. When an account is created by one of our corporate customers, I need to create a folder on the server with the name the customer enters in the form provided. Then I want to transfer an index.php file from the folder [indexes] to the new folder. $adminfield[21] is the variable for the folder name to be created and copied to.
When I run this script, the new folder gets created, but the file doesn't get transferred and I get the following error
Warning: chmod failed: No such file or directory in agent/adminCreateAccount.php on line 275
Warning: Unable to create '/test/index.php': Permission denied in agent/adminCreateAccount.php on line 278
If I comment out chmod I get the following error.
Warning: Unable to create '/test/index.php': Permission denied in agent/adminCreateAccount.php on line 278
I have also included the full path in the copyFrom, copyTo variables and get the same messages.
function ftpConnection($adminfield) {
// create connection
$ftp_server="**";
$conn_id = ftp_connect($ftp_server);
$ftp_user_name="";
// login
$login_result = ftp_login($conn_id, $ftp_user_name, "");
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
die;
}
//change to agent
$dir=ftp_chdir($conn_id,"/visp/public_html/agent/");
//create directory
ftp_mkdir($conn_id,$adminfield[21]);
//name the copyfrom file
$copyFrom="indexes/index.php";
//name the copyto file
$copyTo=".$adminfield[21]."/index.php";
//change permission on file
chmod($copyTo,0777);
//copy from/to
copy($copyFrom,$copyTo);
// close the FTP stream
ftp_quit($conn_id);
}