i search a lot on internet but i don't find a solution. I need copy a file from a ftp to my ftp server through php. Later i need also create a cron job but is another problem.
I tested various script PHP like this below but i receive always the same problem(i try with absolute, normal and other path :) ):
connected Warning: ftp_put(): Can't open that file: No such file or directory in /web/htdocs/www.stanem.it/home/csv/importinnovacsv.php on line 20 There was a problem while uploading /web/htdocs/www.stanem.it/home/csv/test.csv
what i have to do?
<?php
$ftp_server="ftp.xxxx.it";
$ftp_user_name="user";
$ftp_user_pass="psw";
// connect and login to FTP server
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($ftp_conn, $ftp_user_name, $ftp_user_pass);
if($login) {
echo 'connected<br>';
$local_file = '/web/htdocs/www.stanem.it/home/csv/test.csv'; //where i need to put file
$server_dir = 'ftp://15886:[email protected]'; //where i copy the file
// upload a file
if (ftp_put($ftp_conn, $server_dir, $local_file, FTP_ASCII)) {
echo "successfully uploaded $local_file\n";
exit;
} else {
echo "There was a problem while uploading $local_file\n";
exit;
}
}
The $remote_file
argument of ftp_put
is a path to the file on the FTP server.
You are passing a URL (and it even misses any path or file name).
It should be like:
$remote_file = "/remote/path/test.csv";
Once you resolve the path problem, you will also likely face data connection problems, as your are using the default active mode. See PHP ftp_put fails.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments