Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uploading all of files in my local directory with curl

Tags:

I want to upload all the files in one directory, and I know how to upload one file using curl like this :

curl -T "local/xxx.suffix" -u xxx:psw "ftp://192.168.1.158/public/demon_test/xxx.suffix" 

How can I upload all the files (subdirectory) in the current directory to an FTP server?

like image 501
demon Avatar asked Dec 24 '12 10:12

demon


People also ask

How do I send multiple files using curl command?

To post a file with Curl, use the -d or -F command-line options and start the data with the @ symbol followed by the file name. To send multiple files, repeat the -F option several times.

Can I upload with curl?

Uploading files using CURL is pretty straightforward once you've installed it. Several protocols allow CURL file upload including: FILE, FTP, FTPS, HTTP, HTTPS, IMAP, IMAPS, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, and TFTP. Each of these protocols works with CURL differently for uploading data.

How do I download all files in a directory using curl?

To download multiple files at the same time, use –O followed by the URL to the file that you wish to download. If you curl without any options except for the URL, the content of the URL (whether it's a webpage, or a binary file, such as an image or a zip file) will be printed out to screen.


1 Answers

Use curl with find to recursively upload all files from a specific directory:

find mydir -type f -exec curl -u xxx:psw --ftp-create-dirs -T {} ftp://192.168.1.158/public/demon_test/{} \; 
like image 113
dogbane Avatar answered Sep 25 '22 13:09

dogbane