Zado
asked on
Download files from server in zip format.
Hi Experts!
I'm working with Wamp localhost and I use simple script to download files directly from ftp server:
<?php
/* ftp login details here: ftp_login()... */
$source = 'httpdocs/MARINER_DATA/201 3 xml/WK_10/dir;
$local = 'httpdocs/MARINER_DATA/201 3 xml/WK_10/dir/;
$content = ftp_nlist($connection, $source);
foreach ($content as $onefile) {
$destination = $local.$onefile;
if (ftp_get($connection, $destination, $onefile, FTP_BINARY)) {
//success
}
}
?>
Pretty simple. But instead downloading files one by one, I want to create one zip file on server and then download it to localhost. I found nice script allowing you to create zip files based on filepaths from array: http://davidwalsh.name/create-zip-php
It works fine if I run it on localhost and it builds zip file from files on localhost or: run it on online server and build zip file from files on the same online server. But what I want is to request the files from localhost (just send list of files I want in array), create zip file online and then download it from online location to location in localhost, I hope that makes sense to you? It's the only problem and I'd like you to help me with this if possible.
I appreciate your help.
Thanks.
I'm working with Wamp localhost and I use simple script to download files directly from ftp server:
<?php
/* ftp login details here: ftp_login()... */
$source = 'httpdocs/MARINER_DATA/201
$local = 'httpdocs/MARINER_DATA/201
$content = ftp_nlist($connection, $source);
foreach ($content as $onefile) {
$destination = $local.$onefile;
if (ftp_get($connection, $destination, $onefile, FTP_BINARY)) {
//success
}
}
?>
Pretty simple. But instead downloading files one by one, I want to create one zip file on server and then download it to localhost. I found nice script allowing you to create zip files based on filepaths from array: http://davidwalsh.name/create-zip-php
It works fine if I run it on localhost and it builds zip file from files on localhost or: run it on online server and build zip file from files on the same online server. But what I want is to request the files from localhost (just send list of files I want in array), create zip file online and then download it from online location to location in localhost, I hope that makes sense to you? It's the only problem and I'd like you to help me with this if possible.
I appreciate your help.
Thanks.
Are you saying that you want to send the FTP server a list of files and then have the server create a zip file which you then subsequently download? If so, why not just use an FTP server that does compression on the fly?
ASKER
"Are you saying that you want to send the FTP server a list of files and then have the server create a zip file which you then subsequently download?"
Yep, that's exactly what I want.
"If so, why not just use an FTP server that does compression on the fly?"
I'm not sure how to do it/where to start, could you give me some hint, please?
Thanks
Yep, that's exactly what I want.
"If so, why not just use an FTP server that does compression on the fly?"
I'm not sure how to do it/where to start, could you give me some hint, please?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks.
Open in new window
HTH, ~Ray