I am attempting to add code to my current script that will allow for image uploads to the remote server. I have the Perl Cookbook and there is an example for an FTP Client. I modeled that code in a previous script and it worked fine. This time, however, one of the methods I use returns an error. Here's the code:
sub upload_image() {
use Net::FTP;
my $path = $_[0]; # path received from HTML form input - location o
+f image on local machine
my ($username, $password, $directory) = ("xxxx", "xxxx", "/www/path/to
+/store/files");
my $ftp = Net::FTP->new("www.xxxxxxxx.net",
Timeout => 30,
Debug => 1) || die &show_error("Unable
+to connect to ftp: $!");
$ftp->login($username, $password) || die &show_error("Unable to lo
+gin to ftp: $!");
$ftp->cwd($directory) || die &show_error("Unable to change directo
+ry: $!");
$ftp->put($path) || die &show_error("Unable to upload $path: $!");
$ftp->quit();
}
When I run this and make a call to this sub routine the show_error function prints the error "No such directory". Is this referring to the local or remote server? Everything else prior to file upload works. What am I doing wrong?
I know that there are other methods (ie - cgi-lib, Cgi::Upload), but I haven't had much success with getting those to work how I'd like.
Any suggestions or code would be cool.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.