how to use curl --ftp-create-dirs?

馋奶兔 提交于 2019-12-05 12:41:36
Arthur Savage

To add a new directory via FTP:

curl ftp://username:password@10.10.10.10/homes/back/newdir/ --ftp-create-dirs

Just putting this in here for future reference (and because I keep making the same mistake that I just saw in your code): it is important to end your folder name with a / (slash). Otherwise, curl will create a file, not a folder. Here is the command I used:

curl -T path/to/local_file.txt ftp://1.2.3.4/my_new_folder/ --ftp-create-dirs -u username:password

This will move local_file.txt to my_new_folder on the FTP server. The folder will be created if it doesn't exist, otherwise, the command will simply be ignored.

If there are any issues with creating the folder, curl will return error number 9 (see https://curl.haxx.se/libcurl/c/libcurl-errors.html). This can happen if a file with the same name as the new folder already exists in the given directory:

curl: (9) Failed to MKD dir: 451

You don't need to use the /test after the --ftp-create-dirs. Its just a parameter similar to your -k(doesn't take any value) at the command.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!