简体   繁体   中英

Can't transfer files using FTP script and batch on Windows

I have a folder with PDF files locally on hard disk and I want to upload files from this folder to an FTP server.

So I created a batch file that should upload PDF files to the FTP server. Everything seems to work fine and the console window displays File successfully transferred , but actually no file really uploaded.

The FTP script content:

open
000.000.000.000  -- not the real ftp server ip lol 
bla@nirlatpro.com
PASSWORD
mput c:\Batch\*.pdf
quit

Command window with output on running this script:

运行脚本时在控制台窗口中输出行

It looks like it works, but no file is actually uploaded.

What is even more strange is if I connect to FTP using GUI application and drag the files, it does work and all the files are uploaded to the server.

summary: - It's works fine if i'm using windows explore and dragg the files. - It's not uploading the files if i'm using cmd commands or batch script with ftp file, even if the console window displays 'File successfully transferred'

it was a permissions problem apparently the ftp server does not allowing to copy files in to the root directory /

console window display it "Current restricted directory is / "

I too Faced a similar problem downloading a file from ftp through command line, But every time my request was rejected and my connection was not established. After a thorough research i found the ti need to do settings in the IIS for ftp.

Steps:

1) Set your IIS Server on. a:Goto control panel-->Programs&Features-->Turn windows Features on or off-->Internet Information Services. b: Expand the Internet Information services-->Check FTP services-->Expand FTP Server-->FTP Service (Check it)-->press OK.

2)Open IIS Manager(win+r-->inetmgr) a: Select FTP authentication-->Enable Anonymous Authentication or Base Authentication (as per your requirement). b: Select FTP Authorization-->Select All users, give permissions (read or write or both) & press ok. c) Open FTP Directory Browsing select MS-DOS for windows Server or Unix for Unix server.

3) Finally goto Services.msc(win+r-->'services.msc')-->MicrosoftFTPServices-->restart.

Now goto your command prompt and write your respective code for ftp it will work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM