Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to download zip file from FTP

Posted on 2009-05-04
8
Medium Priority
?
398 Views
Last Modified: 2012-05-06
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
Comment
Question by:tankergoblin
  • 5
  • 3
8 Comments
 
LVL 25

Expert Comment

by:lwadwell
ID: 24301785
Hi tankergoblin,

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

lwadwell
0
 
LVL 7

Author Comment

by:tankergoblin
ID: 24301802
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
 
LVL 7

Author Comment

by:tankergoblin
ID: 24301806
do i need to add anything to $ftp->binary
like $ftp->binary(...)??
0
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!

 
LVL 7

Author Comment

by:tankergoblin
ID: 24301823
Mind to tell me how to extract a zip file??
0
 
LVL 25

Accepted Solution

by:
lwadwell earned 2000 total points
ID: 24301852
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
 
LVL 7

Author Comment

by:tankergoblin
ID: 24301885
Im using Winzip and i use 'use Archive::Zip;' in perl
0
 
LVL 7

Author Comment

by:tankergoblin
ID: 24301891
on windows pc i would like to extract the file
0
 
LVL 25

Expert Comment

by:lwadwell
ID: 24301921
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question