in reply to Struggles with Put in Net::FTP

You need to get more info on what is causing the failure
$ftp->put ( $input_file, $new_file_name ) or die "did not upload $inpu +t_file to $new_file_name: " . $ftp->message;
Maybe the problem is in $new_file_name?
use File::Basename wq(basename); my $new_file_name = basename($input_file); die "no such file: $input_file" unless -s $input_file; $ftp->put ( $input_file, $new_file_name ) or die "did not upload $inpu +t_file to $new_file_name: " . $ftp->message;
Test it against your own FTP server running with verbose logging and see what the FTP server logs report?

Regards,

Jeff

Replies are listed 'Best First'.
Re: Re: Struggles with Put in Net::FTP
by Anonymous Monk on May 25, 2004 at 18:26 UTC
    Try e:\\test\\picture.jpg
Re: Re: Struggles with Put in Net::FTP
by mchiles (Initiate) on May 25, 2004 at 22:25 UTC
    Jeff-

    You may be on the right track...

    Maybe the problem is in $new_file_name?
    use File::Basename wq(basename); my $new_file_name = basename($input_file); die "no such file: $input_file" unless -s $input_file;
    The first two lines of this gave me problems, with the error:
    Undefined subroutine &main::wq called at /home/auctionb/public_html/cgi-bin...bla, bla

    But the third line (the die line) got me an interesting error message (when the first two lines were commented out):

    no such file: e:\test\picture.jpg at /home/auctionb/public_html/cgi-bin/auction/bulklister.pl line 280.

    It looks to me, based on this, that it can't find my input file, e:\\test\\picture.jpg. So why is that? It looks to me that for some reason the script (at the host) is not looking for the file at my local computer... ideas?

    You also advised:
    Test it against your own FTP server running with verbose logging and see what the FTP server logs report?
    You will have to excuse my technical ignorance here, but I am not sure what you mean or how to do it. :(

    -Matt :)
      If I understood this correctly, the script using Net::FTP is on a linux machine, your webhost, and the file you would like to upload (to where?) is on your home PC?? Even if you are running the script as a CGI from your home PC via a browser, it is still running locally on the linux system, and will NOT be able to see your PC files.

      To copy files from your home PC to somewhere else via such a CGI, you'll need to use the CGI upload functions to upload the file from the PC to the linux server first, then use Net::FTP to copy it elsewhere.

      C.

        You understand correctly, the script that is using Net::FTP is on a linux machine which is my webhost. I am attempting to have the script upload a file from my home PC (a Windows 98 machine) to a directory on the linux machine.

        So what you are saying, if I am understanding correctly, is that what I am trying to do is not something that Net::FTP is designed to do - ie, act as an FTP program between the linux server and my home computer...

        If this is the case, it appears that I have a fundamental misunderstanding of Net::FTP and its capabilities. So I guess my question then would be can Net::FTP be used to have a script upload a file from a users home PC to the machine that the script is running on on the internet?

        If not, is there another way to do this or can it only be done via the <FORM ENCTYPE=multipart/form-dat... method?

        What I am overall attempting to do, which Net::FTP is a part of, is for a user to upload a comma delimnated text file (which is done via FORM), and then have the script pull fields from that file which include description fields and a local file location for a .jpg file. The script will then upload the .jpg file (theoritically via Net::FTP) and take the other elements from the previously uploaded text file to write new data files locally (on the host). Everything else about the script is working except the Net::FTP - but perhaps I am fundamentally wrong in supposing what Net::FTP is supposed to do...

        -Matt :)