Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

net::ftp problem

Status
Not open for further replies.

math

Programmer
Mar 21, 2001
56
BE
hi,

I have a problem with the net::ftp module... well, I think that I've found the problem (THINK) but I have no idea how to solve it... I'll try to explain it...

The user can send a file through a form (with browse button) the URL to that file is something like "C:\file.txt" and I think that the script thinks that that file is on the host-computer (locally) so the script tries to upload a file that doesn't exist... the file is on the users computer and not on the host... IT HAS TO BE FTPed to the host... Anyone have an idea how to solve this?? or does anyone have an other idea why the script only works on the host-computer and not on other computers??

Thanks,
math
 
There are a couple of FAQs about uploading files. However, neither of them use net::ftp. Rather, they use the CGI libs/modules. I don't have any experience using net::ftp, but, maybe one of the CGI approaches will work for you.

faq219-406 - uploading with CGI.pm
faq219-352 - uploading with CGI_Lite.pm and cgi-lib.pl

HTH


keep the rudder amid ship and beware the odd typo
 
thanks Goboating, but I already explored these options before... The script I need is for very big files and with those other methodes, the filesize never seems correct and the files are useless... that's why FTP seemd the answer, but I think net::ftp isn't used for internet-scripts but rather for local-scripts...

Does anyone have a working example in which a user can upload a local file to a ftp-server using net::ftp???
Or does anyone have an answer for what I think is the problem?

Greetings,
math
 

Hey Math,

That's exactly what I'm working on right now too.

I'm writing a script that goes onto a local windows machine and syncronizes the web files with your local ones via Net::FTP;

I'm also having trouble at the moment and that's why I'm here but I'll be sure to let you know when I figure out how to transfer a file with it.

Tony
 
Ok Mate, I've got a working example of how to upload/download files from a server, I'm on a windows machine too, to install the module if you don't have it on your box, just down load the libnet package, you can search for "ftp" at scroll to the bottom and you'll see it, click on libnet above Net::FTP;

Then unzip the tar file, if you have winzip 8.0 it'll do .tar files and all that, then just paste the .pm files into the Net folder in the lib directory where ever you installed perl, in my case, C:\Perl\lib\Net

It's really that simple since there's no code to be compiled. Some of the other modules may not work though, I know that Config.pm, ftp.pm and cmd.pm will though because they are all used when you say use Net::FTP;

Ok, that's as far as I got last night, now for the code,

print "Content-type: text/html\n\n";
$host = "Domain or Ip address, no use Net::FTP;
$ftp = Net::FTP->new("$host", Debug => 0);
$ftp->login("USERNAME",'PASSWORD');
# $ftp->cwd("/The/upload/directory");
# $ftp->binary(); # For transfering binary files
$ftp->ascii();
# $ftp->get("/full/path/to/file");
$ftp->put("C:\\path\\to\\file.txt");
$ftp->quit;
print "Done";

And it worked like a charm for me, I read in the cpan docs that when they tested this module, they couldn't upload because their server didn't allow it or something, I know mine does since I ftp to it all the time with a sharware program I got, but you might have that problem if you can get it to work.

Ok, I hope this helps,

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top