Connected as xxx@x.x.x.x Warning: ftp_get() [function.ftp-get]: The system cannot find the file specified. in /xxx/mapload.php on line 62 There was a problem downloading the file. /scriptfiles/maps/James_1.txt |
$resultPath = "/scriptfiles/maps/" . $_POST['pname'] . "_" . $_POST['slot'] . ".txt";
$ftp_server = "...";
$ftp_user = "...";
$ftp_pass = "...";
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) echo "Connected as $ftp_user@$ftp_server\n";
else echo "Couldn't connect as $ftp_user\n";
$local_file = 'map.txt';
$server_file = '$resultPath'; // Also tried without apostrophes (')
if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) echo "Successfully written to $local_file\n";
else echo "There was a problem downloading the file.\n";
// close the connection
ftp_close($conn_id);
<?php
$file = 'example.txt';
$newfile = 'example.txt.bak';
if (!copy($file, $newfile)) {
echo "error to copy file: $file...\n";
}
?>
<?php $ftp_host = "serverhostname ex: could be a ip address"; //put the ip / hostname to your ftp here $ftp_user = "ftp login"; //put your login here $ftp_pass = "ftp password"; //put your password here $con = ftp_connect($ftp_host) or die("Couldnt connect to your ftp (check your settings!"); ftp_login($con, $ftp_user, $ftp_pass); ftp_get($con, "/scriptfiles/maps/", FTP_ASCII); ftp_close($con); $file = fopen("/scriptfiles/maps/", "r"); fclose($file); ?>
<?php $ftp_host = "serverhostname ex: could be a ip address"; //put the ip / hostname to your ftp here $ftp_user = "ftp login"; //put your login here $ftp_pass = "ftp password"; //put your password here $mapfile = "/scriptfiles/maps/"; $con = ftp_connect($ftp_host) or die("Couldnt connect to your ftp (check your settings!"); ftp_login($con, $ftp_user, $ftp_pass); ftp_get($con, "/scriptfiles/maps/, $mapfile, FTP_ASCII); ftp_close($con); $file = fopen("/scriptfiles/maps/", "r"); $maps = fread($file, filesize("/scriptfiles/maps/")); fclose($file); echo nl2br($maps); ?>
<?php
header("Content-disposition: attachment; url=the ftp url here with file location and file name");
header('Content-type: text/plain');
readfile($myvariable);
?>