Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Currently I know how to do this:

curl -T file.zip ftp://server.domain.com/ --user username:password

Which will let me do a single file. However I can't figure out how to do it for a directory. I would like to use a similar command and specify a directory instead of a single file and have it upload that directory and all contents maintaining folder structure. How is that done?

share|improve this question

You probably have to use something more sophisticated. FTP itself (if I remember correctly) is not able to transfer entire directories, all it knows about is transferring a file. Thus the client has to translate your request "send this directory" into a sequence of upload this file (possibly preceded by make this directory).

One such sophisticated client is lftp (see also Wikipedia), its mirror -R command should do the job.

(ncftp's ncftpput has a -R flag for this, too.)

Edit Of course you can also do a recursive upload with find and curl's --ftp-create-dirs flag..

share|improve this answer
Your find / curl link is broken, unfortunately. Better copy instead of linking to any URL that doesn't appear rock-solid. – dan3 Jun 17 '13 at 11:03
There are no rock-solid URLs ;) But luckily there is the internet archive wayback machine. – sr_ Jun 17 '13 at 19:47
Well, links to stack-overflow would be rock-solid, links to Google News, sourceforge mailing list archives... Anyway, the link says find -type f -exec curl -v -u myusername:mypassword --ftp-create-dirs -T {} ftp3.ftptoyoursite.com/www.mynewwebsite.com/web/content{} \; – dan3 Jun 17 '13 at 20:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.