• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 405
  • Last Modified:

How to download zip file from FTP

Hi How to download zip file from FTP i have use code below:

$ftp->get("remote","local")or $newerr=1;


I successfully download the zip file but failed to open it.

i get error message below:

zip file corrupt, possible cause: file transfer error.
0
tankergoblin
Asked:
tankergoblin
  • 5
  • 3
1 Solution
 
lwadwellCommented:
Hi tankergoblin,

Are you using Net::FTP?  If so, are you ensuring the transfer is in binary mode first?  $ftp->binary;

lwadwell
0
 
tankergoblinAuthor Commented:
yes im using net::FTP
where should i put  $ftp->binary;, above $ftp->get?

like this???

$ftp=Net::FTP->new
$ftp->login
$ftp->cwd
@files2=$ftp->ls
****$ftp->binary
$ftp->get
0
 
tankergoblinAuthor Commented:
do i need to add anything to $ftp->binary
like $ftp->binary(...)??
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
tankergoblinAuthor Commented:
Mind to tell me how to extract a zip file??
0
 
lwadwellCommented:
tankergoblin,

Yes, the $ftp->binary should be above the $ftp->get;  Transfers will be ascii by default - which is great for text file where you want the line terminators converted and some other special characters.  But for files like .zip ... you need to transfer it exactly without any translations, hence do it as binary.

No the $ftp->binary; requires no arguments - just use like that.

On what type of platform do you want to extract the file and do you have any zip tools installed (e.g on Windows - winzip or 7zip or pkzip or ... there probably hundreds of different ones).


lwadwell
0
 
tankergoblinAuthor Commented:
Im using Winzip and i use 'use Archive::Zip;' in perl
0
 
tankergoblinAuthor Commented:
on windows pc i would like to extract the file
0
 
lwadwellCommented:
tankergoblin,

with WinZip - generally you can right click on the .zip file and an option to extract files should appear in the menu (I do not use WinZip myself).

with Archive::Zip - this can extract files but this generally used to create zip files.  It is recommended to use Archive::Extract instead.  I have never programmed with either but the help pages look simple enough.

lwadwell
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now