Jump to content

Archived

This topic is now archived and is closed to further replies.

toter

php HELP

Recommended Posts

I am trying to copy a file using the copy function and when the page is loaded the coppied file is blank?

[code]
<?php
// set up basic connection
$ftp_server = "<host>";
$conn_id = ftp_connect($ftp_server);

// login with username and password
$ftp_user_name = "<username>";
$ftp_user_pass = "<password>";
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// get contents of the current directory
$path = $_SERVER['REQUEST_URI'];
$path = "public_html" . $path;
$contents = ftp_nlist($conn_id, $path);

// Create Folder if user wants to
if($_POST['action'] == 'Create'){

$dir_name = $path . $_POST['dir_name'] . '/';
ftp_mkdir($conn_id, $dir_name);
$template_file = 'ftp://<username>:<password>@<host>/path/to/index.php';
$index_file =  'ftp://<username>:<password>@<host>/' . $dir_name . 'index.php';
copy($template_file,$index_file);
}
?>
[/code]

thanks,
TT

Share this post


Link to post
Share on other sites
i am also having trouble with this simple bit of code:
[code]
<?php
copy('file.php','newfile.php');
?>
[/code]
i get an error of this:

Warning: copy(newfile.php): failed to open stream: Permission denied in /home/<username>/public_html/leaders/tod/copy.php on line 2

but all my files and folders permissions are set to 777

any body know?

thanks a bunch,
TT

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.