I\'m trying to upload a file to FTP.
Here is my code:
$connect = ftp_connect(\'ftp.my-server.fr\');
$login = ftp_login($connect, \'username\', \'pass
Your $local_file
is OK, but your $remote_file
is a directory (you use '/' . $date
for ftp_chdir
), and it need to be a path to a file (that will be created)
You can copy the same filename than the local file with basename
:
$remote_dir = '/' . $date;
$local_file = fopen('C:/MAMP/htdocs/mysite/myfolder/' . $hour .'.mp3', 'r');
ftp_chdir($connect, $remote_dir);
$remote_file = $remote_dir . '/' . basename($local_file) ;
if (ftp_fput($connect, $remote_file, $local_file, FTP_ASCII)) {
echo "The file $local_file has been loaded";
} else {
echo "Error while uploading file " . $local_file;
}