wput: Upload to FTP subdirectory

Saturday, August 23rd, 2014

Uploading a file via wget to a FTP subdirectory without mentioning the absolute path didn’t work.

$f = /home/my/files/image.jpg
wput -B -v –basename=/home/my/files $f ftp://user:password@

Logging in as user … Logged in!
==> CWD images/
==> TYPE I … done.
==> SIZE /image.jpg … failed.
==> PASV … done.
==> STOR /image.jpg … Send Failed (/image.jpg: Permission denied.) Skipping this file

It seems wput needs the absolute path name on the FTP server.


basename does the trick. It strips the path from the passed absolute url.

$f = /home/my/files/image.jpg
wput -B -v –basename=/home/my/files $f ftp://user:password@$(basename $f)