|
Posted by pangea33 on 11/22/06 01:36
Paul wrote:
> I need to copy files from an ftp directory to a web-accessible directory and
> then delete the files in the ftp directory. (I am doing it this way because
> web-based form upload can not exceed 2MB and I can't change that)
>
> Any ideas are much appreicated!
You can put a script like this on your webserver with the correct info,
then just run it in your browser. It will move the file.
<?php
$ftp_server = 'ftp.domain.com';
$ftp_user_name = 'ftpuser';
$ftp_user_pass = 'ftppass';
$server_file = '/ftppathtofile.ext';
$local_file = '/dirpathtofile.ext';
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed.\n";
echo "Attempted to connect to $ftp_server for user $ftp_user_name.\n";
exit;
} else {
echo "Connected to $ftp_server.\n";
}
//DOWNLOAD
$download = ftp_get($conn_id, $local_file, $server_file, FTP_BINARY);
if ($download) {
echo "Successfully written to $local_file\n";
} else {
echo "There was a problem\n";
}
ftp_close($conn_id);
?>
Navigation:
[Reply to this message]
|