You are here: Re: how to copy files from ftp directory to web-accessible directory? « All PHP « IT news, forums, messages
Re: how to copy files from ftp directory to web-accessible directory?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация