Php - Open Zip File on FTP Server

Php - Open Zip File on FTP Server

Cancelled

Job Description

I need to write an ftp script that will log into an ftp server, locate a zip file and then extract or save the contents (photos) on my server.

I log into the ftp server by using the below code which works fine.

<?php
$ftp_server = "IDXProf.metrolist.com";
$ftp_user = "CR**";
$ftp_pass = ")Up7h*****";

// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
echo "Connected as $ftp_user@$ftp_server\n";
$contents = ftp_nlist($conn_id, ".");
print "<pre>";
print_r($contents);
print "</pre>";

mychdir($conn_id,'IDX_Version_6');

$contents = ftp_nlist($conn_id, ".");
print "<pre>";
print_r($contents);
print "</pre>";

} else {
echo "Couldn't connect as $ftp_user\n";
}

// close the connection
ftp_close($conn_id);
//fclose($handle);

function mychdir($conn_id,$newdir) {
if (ftp_chdir($conn_id, $newdir)) {
echo "Current directory is now: " . ftp_pwd($conn_id) . "\n";
} else {
echo "Couldn't change directory\n";
}
}

?>

Attached is a screen shot of what is on the server. You can see the list of files that are on the ftp server. I need a script that will open the zip files (not the txt files) and save the photos into a folder on my server.

Open Attachment