Jump to content

Automatically get zip file via FTP


nicole86

Recommended Posts

Hello, I am new here but I hope you can help me with a problem that I've been stuck with for days.

 

I am trying to populate the content of a website through XML files (zipped) that are located on an FTP server.

 

I managed to get the zip file but I'm not sure if it is the correct way:

 

function ftp_copy($file) {
$conn_id = ftp_connect($ftp_host) or die ("Can't connect");
        $ftp_login= ftp_login($conn_id, $ftp_user, $ftp_pass) or die ("Can't login");
ftp_pasv($conn_id, true);
        ftp_chdir($conn_id, "/zip_files/");
return ftp_get($conn_id, $file, $file, FTP_BINARY);
}

ftp_copy('1001.zip');

 

After that I will need to extract the zip file. I'm planning to use pclzip library for it and save the contents on a database.

Also this has to happen everyday so I'm thinking about using a cron job, although hourly is also preferable since the XML files could be generated more than once per day.

 

Am I doing it the right way or is there a better solution for this?

 

Any help will me much appreciated! Thanks a lot!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.