Solved

How to download zip file from FTP

Posted on 2009-05-04
8
381 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…

735 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