I can\'t succeed to upload a multiple files to some FTP by batch file I made.
Also, I want to upload all files from this local directory.
The code:
FTP command allows sending multiple files but if we want directories and sub-directories auto created and transferred then alternatively, we can use ncftp. Steps below:
Syntax:
ncftpput -u username -p password -m -R SERVER_IP_ADDRESS /remote_directory local_directory\*
Example:
ncftpput -u ftpuser1 -p ftppass1 -m -R 192.168.1.10 /var/www C:\public_html\*
The switches used are:
-u: FTP username
-p: FTP password
-m: Attempt to make the remote destination directory before copying.
-R: Recursive mode; copy whole directory trees
Use the prompt command to turn off transfer confirmation prompts:
Toggles prompt mode on and off.
Without it, tje ftp
uses the following commands in the script (the close
and the quit
in your case) as answers. As they are not y
, the transfer is skipped.
Another option with the same effect is using the -i
switch on the ftp command-line:
-i : Disables interactive prompting during multiple file transfers.
This should do it:
ftp -i -s:"C:\automation\fileup.bat" MYSERVER.COM
And in your script, end it like this:
mput *
bye