#!/usr/bin/perl use lib '.'; use strict; use warnings; use WebService::Dropbox; use IO::File; my $filename = '/var/www/vhosts/path/httpdocs/path/file.txt'; my $access_token = ''; # TOKEN goes here my $key = ''; # APPLICATION KEY goes here my $secret = ''; # APPLICATION SECRET goes here my $dropbox = WebService::Dropbox->new({ key => $key, # this should be KEY, not TOKEN secret => $secret, # this should be SECRET, not skipped # oauth2 is true by default for recent versions }); $dropbox->access_token($access_token); # must send dropbox the access token AFTER the key/secret was defined when object was instantiated my $local_file = $filename; my $remote_path = '/Uploads/$filename'; my $content = IO::File->new($local_file, '<') or die "Cannot open $local_file: $!"; my $result = $dropbox->upload($remote_path, $content); if ($result) { print "Successfully uploaded $local_file to Dropbox as $remote_path\n"; } else { die "Upload failed: " . $dropbox->error; }