Solved

How to download zip file from FTP

Posted on 2009-05-04
8
378 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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 500 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Perl, group, sort, count question 6 136
perl CPAN issue 3 111
Having a problem with ActiveState Perl on 64-bit Windows 7 3 73
Perl script to delete older files 6 88
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…

825 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