Here's an example of the code I'm trying to combine, to retrieve the contents of a file on a remote server and put them in a <textarea>:
Code: Select all
<?php
$conn = ftp_connect("ftp.domain.com");
ftp_login($conn, "username", "password");
ftp_pasv($conn, true);
$filename='example.php';
// open file
$fh = fopen($filename, "r") or die("Could not open file!");
// read file contents
$datax = fread($fh, filesize($filename)) or die("Could not read file!");
$data=htmlspecialchars($datax);
// close file
fclose($fh);
// close this connection
ftp_close($conn);
echo '<textarea cols="200%" rows="50">'.$data.'</textarea>';
?>Code: Select all
<?php
$filename='editor.php';
$fh = fopen("ftp://username:password@domain.com/example.php", "r") or die("Could not open file!");
$datax = fread($fh, filesize($filename)) or die("Could not read file!");
$data=htmlspecialchars($datax);
fclose($fh);
echo '<textarea cols="200%" rows="50">'.$data.'</textarea>';
?>