in reply to Re: Struggles with Put in Net::FTP
in thread Struggles with Put in Net::FTP

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 :)

Replies are listed 'Best First'.
Re: Re: Re: Struggles with Put in Net::FTP
by castaway (Parson) on May 26, 2004 at 05:33 UTC
    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 :)
        I think I'm beginning to understand what you are wanting to do. The Net::FTP script is on the Linux server and its trying to connect to a Win98 PC to get a file? If so, then you need:

        A) to make sure there is an FTP server running on the PC
        B) you want to use the 'get' method ($ftp->get('$remote_file','$local_file');)

        I think I am understanding you properly. If you are attempting to use Net::FTP to connect to a machine that does not have an FTP server running, then you will not be able to do this. I've never really used CGI.pm but I think castaway has the right of it.

        Yes, and no.
        Net::FTP can connect TO a another machine, running an FTP server, and either fetch from or upload to that server. Which machine are you telling your Net::FTP connection to connect to? (My guess would be its the linux machine again, which makes no sense, that would only be useful for transferring files from linux to linux).

        I think you are confused about where the script with Net::FTP is running. Its running on the linux webhost. So any connections it makes are from there. If you need to transfer files from your PC to the linux webhost, you need to connect to your PC, and do a GET operation, not a PUT.

        This would require that your PC is running an ftp server, which it probably isnt. (Windows doesnt come with one, unless you have IIS installed.)

        You are using Net::FTP incorrectly, yes. Read up on CGI.pm and how it can be used to upload files. (theres a tutorial on perlmonks somewhere, I believe).

        C.